diff options
| author | seth <[email protected]> | 2024-02-08 21:20:58 -0500 |
|---|---|---|
| committer | seth <[email protected]> | 2024-02-09 01:17:16 -0500 |
| commit | 3f19e4f7420916c45d6c8a1cab5b476b1c863ed0 (patch) | |
| tree | 329d3a079d1d4a6424104a4c1d27062fdf08f9f5 /lib | |
| parent | ac05391c228b1630614e6585124f183a90489414 (diff) | |
lib/deploy: init
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/deploy.nix | 39 |
1 files changed, 39 insertions, 0 deletions
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); +} |
