aboutsummaryrefslogtreecommitdiff
path: root/modules/default.nix
blob: 91ab2916d9be97449b0c355c6793846333e3d333 (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
{ inputs }:
let
  genModules =
    { type, modules }: builtins.map (module: "${inputs.self}/modules/${type}/${module}") modules;

  mkModules = moduleAttrList: builtins.concatMap (moduleAttr: genModules moduleAttr) moduleAttrList;
in
{
  mkSystem = hostname: system: nixpkgsVersion: modules: rec {
    deploy.nodes.${hostname} = {
      inherit hostname;
      profiles.system = {
        user = "root";
        sshUser = "tdback";
        path = inputs.deploy-rs.lib.${system}.activate.nixos nixosConfigurations.${hostname};
      };
    };

    nixosConfigurations.${hostname} = nixpkgsVersion.lib.nixosSystem {
      inherit system;
      modules = (mkModules modules) ++ [
        "${inputs.self}/hosts/${hostname}"
        "${inputs.self}/modules/users"
        inputs.home-manager.nixosModules.home-manager
        inputs.agenix.nixosModules.default
      ];
      specialArgs = { inherit inputs; };
    };
  };

  mergeSets = inputs.nixpkgs.lib.lists.foldl' (
    x: y: inputs.nixpkgs.lib.attrsets.recursiveUpdate x y
  ) { };
}