summaryrefslogtreecommitdiff
path: root/parts/lib/utils.nix
blob: f830b1cec4e348b90e40d7fce5d964fffc15a2bb (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
{
  self,
  inputs,
  withSystem,
  ...
}: let
  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;
        };
      })
    ];
  };
in {
  mkDeployNodes = 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;
}