-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigurations.nix
29 lines (26 loc) · 1.02 KB
/
configurations.nix
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
{ self, ... }:
with self.inputs.nixpkgs.lib;
let
# Function to create an overridable nixosSystem
nixosSystem = makeOverridable self.inputs.nixpkgs.lib.nixosSystem;
# List of .nix files in './hosts'
nixosConfigurations = mapAttrs' (name: value:
# call nixosSystem for each host in the './hosts/' directory
let
system = nixosSystem {
# self will always infinite recursion when used in module imports, so must be passed as specialArgs to access nixosModules
specialArgs = { inherit self; };
modules = [ { _module.args = { inherit self; } // self.inputs; } # making self and inputs available to modules
(./. + "/hosts/${name}") # importing the host config
];
};
in nameValuePair
(system.config.networking.hostName)
(system))
# list host configurations from ./hosts/
(filterAttrs
(attr: value: value == "regular" && hasSuffix ".nix" attr)
(builtins.readDir ./hosts));
in {
flake = { inherit nixosConfigurations; };
}