summaryrefslogtreecommitdiff
path: root/lib/deploy.nix
blob: fa15dc63b0370f92ea7f22f07148f3f9eca08eb4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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);
}