summary refs log tree commit diff stats
path: root/hosts/default.nix
blob: f53ee35f6a337cc86eb872394d68d5738d57ee95 (plain) (blame)
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
40
41
{
  pkgs,
  nixLib,
  nixpkgs,
  specialArgs,
  extraModules,
  deployPackage,
}: let
  hostnames = builtins.fromTOML (builtins.readFile ./host-names.toml);

  hosts = nixLib.mkByName {
    useShards = false;
    baseDirectory = ./by-name;
    fileName = "configuration.nix";
    finalizeFunction = name: value: value;
  };

  mkNixosConfiguration = _: value:
    nixpkgs.lib.nixosSystem {
      system = "x86_64-linux";
      inherit specialArgs;
      modules =
        extraModules
        ++ [
          ../modules
          value
        ];
    };
  nixosConfigurations = builtins.mapAttrs mkNixosConfiguration hosts;

  mkDeploy = name: _: {
    hostname = hostnames."${name}";
    profiles.system = {
      user = "root";
      path = deployPackage.lib.activate.nixos nixosConfigurations."${name}";
    };
  };
  deploy = {nodes = builtins.mapAttrs mkDeploy hosts;};
in {
  inherit nixosConfigurations deploy;
}