From 3f19e4f7420916c45d6c8a1cab5b476b1c863ed0 Mon Sep 17 00:00:00 2001 From: seth Date: Thu, 8 Feb 2024 21:20:58 -0500 Subject: lib/deploy: init --- lib/deploy.nix | 39 +++++++++++++++++++++++++++++++++++++++ systems/default.nix | 16 +++++++++++++--- systems/deploy.nix | 44 -------------------------------------------- 3 files changed, 52 insertions(+), 47 deletions(-) create mode 100644 lib/deploy.nix delete mode 100644 systems/deploy.nix diff --git a/lib/deploy.nix b/lib/deploy.nix new file mode 100644 index 0000000..fa15dc6 --- /dev/null +++ b/lib/deploy.nix @@ -0,0 +1,39 @@ +{ + lib, + inputs, + ... +}: let + inherit (inputs) self; + configurations = self.nixosConfigurations // self.darwinConfigurations; + + getDeploy = pkgs: + (pkgs.appendOverlays [ + inputs.deploy.overlay + (_: prev: { + deploy-rs = { + inherit (pkgs) deploy-rs; + inherit (prev.deploy-rs) lib; + }; + }) + ]) + .deploy-rs; + + toType = system: + { + "Linux" = "nixos"; + "Darwin" = "darwin"; + } + .${system}; + + toDeployNode = hostname: system: { + sshUser = "root"; + inherit hostname; + profiles.system.path = let + deploy = getDeploy system.pkgs; + type = toType system.pkgs.stdenv.hostPlatform.uname.system; + in + deploy.lib.activate.${type} system; + }; +in { + mapNodes = targets: lib.mapAttrs toDeployNode (lib.getAttrs targets configurations); +} diff --git a/systems/default.nix b/systems/default.nix index e0fa49b..7160c96 100644 --- a/systems/default.nix +++ b/systems/default.nix @@ -1,6 +1,8 @@ -{inputs, ...}: { - imports = [./deploy.nix]; - +{ + inputs, + self, + ... +}: { configurations = { nixos = { builder = inputs.nixpkgs.lib.nixosSystem; @@ -34,4 +36,12 @@ }; }; }; + + flake.deploy = { + remoteBuild = true; + fastConnection = false; + nodes = self.lib.deploy.mapNodes [ + "atlas" + ]; + }; } diff --git a/systems/deploy.nix b/systems/deploy.nix deleted file mode 100644 index fbf20d3..0000000 --- a/systems/deploy.nix +++ /dev/null @@ -1,44 +0,0 @@ -{ - lib, - inputs, - self, - ... -}: let - targets = ["atlas"]; - configurations = self.nixosConfigurations // self.darwinConfigurations; - - getDeploy = pkgs: - (pkgs.appendOverlays [ - inputs.deploy.overlay - (_: prev: { - deploy-rs = { - inherit (pkgs) deploy-rs; - inherit (prev.deploy-rs) lib; - }; - }) - ]) - .deploy-rs; - - toType = system: - { - "Linux" = "nixos"; - "Darwin" = "darwin"; - } - .${system}; - - toDeployNode = hostname: system: { - sshUser = "root"; - inherit hostname; - profiles.system.path = let - deploy = getDeploy system.pkgs; - type = toType system.pkgs.stdenv.hostPlatform.uname.system; - in - deploy.lib.activate.${type} system; - }; -in { - flake.deploy = { - remoteBuild = true; - fastConnection = false; - nodes = lib.mapAttrs toDeployNode (lib.getAttrs targets configurations); - }; -} -- cgit v1.2.3