summaryrefslogtreecommitdiff
path: root/lib/host.nix
blob: 767124c722c0b43ce6cf65b9a3a06e756797bd01 (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
40
41
42
43
44
45
46
47
{mapFilterDirs}: rec {
  mkHost = {
    name,
    modules,
    specialArgs ? {},
    system ? "x86_64-linux",
    stateVersion ? "22.11",
    pkgs,
    inputs,
  }:
    with pkgs.lib;
      nixosSystem {
        inherit system specialArgs;
        modules =
          [
            ../modules
            ../hosts/${name}

            {
              system.stateVersion = stateVersion;
              networking.hostName = mkDefault name;

              nixpkgs = {
                overlays = with inputs; [nur.overlay getchoo.overlays.default];
                config.allowUnfree = true;
              };
              nix.registry.getchoo.flake = inputs.getchoo;

              nixos.enable = true;
            }
          ]
          ++ modules;
      };

  mapHosts = inputs: let
    hosts = import ../hosts inputs;
  in
    mapFilterDirs ../hosts (n: v: v == "directory" && n != "turret") (name: _:
      mkHost {
        inherit name inputs;
        inherit (hosts.${name}) modules system stateVersion pkgs;
        specialArgs =
          if builtins.hasAttr "specialArgs" hosts.${name}
          then hosts.${name}.specialArgs
          else {};
      });
}