diff options
Diffstat (limited to 'parts')
| -rw-r--r-- | parts/default.nix | 1 | ||||
| -rw-r--r-- | parts/deploy.nix | 49 | ||||
| -rw-r--r-- | parts/dev.nix | 20 |
3 files changed, 61 insertions, 9 deletions
diff --git a/parts/default.nix b/parts/default.nix index fa5cf95..dc01879 100644 --- a/parts/default.nix +++ b/parts/default.nix @@ -1,5 +1,6 @@ {inputs, ...}: { imports = [ + ./deploy.nix ./dev.nix ./overlays ]; diff --git a/parts/deploy.nix b/parts/deploy.nix new file mode 100644 index 0000000..bebf25c --- /dev/null +++ b/parts/deploy.nix @@ -0,0 +1,49 @@ +{ + self, + inputs, + lib, + withSystem, + ... +}: let + systems = ["atlas" "p-body"]; + + deployedSystems = + lib.filterAttrs + (n: _: builtins.elem n systems) + self.nixosConfigurations; + + deployPkgs = import inputs.nixpkgs rec { + system = "x86_64-linux"; + overlays = [ + inputs.deploy-rs.overlay + (_: prev: { + deploy-rs = { + inherit (withSystem system (p: p.pkgs)) deploy-rs; + inherit (prev.deploy-rs) lib; + }; + }) + ]; + }; + + mkNodes = hosts: let + inherit (builtins) attrNames listToAttrs map; + vals = + map (name: let + system = self.nixosConfigurations.${name}; + in { + inherit name; + value = { + sshUser = "root"; + hostname = system.config.networking.hostName; + profiles.system.path = deployPkgs.deploy-rs.lib.activate.nixos system; + }; + }) + (attrNames hosts); + in + listToAttrs vals; +in { + flake.deploy = { + remoteBuild = true; + nodes = mkNodes deployedSystems; + }; +} diff --git a/parts/dev.nix b/parts/dev.nix index c190008..c0b5490 100644 --- a/parts/dev.nix +++ b/parts/dev.nix @@ -25,15 +25,17 @@ devShells = { default = pkgs.mkShell { inherit (self.checks.${system}.pre-commit-check) shellHook; - packages = with pkgs; [ - actionlint - alejandra - deadnix - just - inputs.ragenix.packages.${system}.ragenix - statix - stylua - ]; + packages = with pkgs; + [ + actionlint + alejandra + deadnix + just + inputs.ragenix.packages.${system}.ragenix + statix + stylua + ] + ++ lib.optional (system == "x86_64-linux") deploy-rs; }; }; |
