-
Notifications
You must be signed in to change notification settings - Fork 1
/
lib.nix
41 lines (41 loc) · 1.37 KB
/
lib.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
30
31
32
33
34
35
36
37
38
39
40
41
let
defineSystems = inputs: let
systems = builtins.mapAttrs (k: _v: builtins.readDir ./systems/${k}) (builtins.readDir ./systems);
configuration = builder: system: hostName:
builder {
inherit system;
specialArgs = {
inherit inputs;
inherit system;
inherit hostName;
};
modules = [
./systems/${system}/${hostName}/configuration.nix
];
};
configurationAttrs = builder: arch:
builtins.map (hostName: {
name = hostName;
value = builder arch hostName;
}) (builtins.attrNames systems.${arch});
nixosConfiguration = arch: hostName:
configuration inputs.nixpkgs.lib.nixosSystem arch hostName;
nixosConfigurations = let
nixosConfigurationAttrs = aarch: configurationAttrs nixosConfiguration aarch;
in
builtins.listToAttrs (nixosConfigurationAttrs "aarch64-linux" ++ nixosConfigurationAttrs "x86_64-linux");
darwinConfiguration = arch: hostName:
configuration inputs.nix-darwin.lib.darwinSystem arch hostName;
darwinConfigurations = let
darwinConfigurationAttrs = aarch: configurationAttrs darwinConfiguration aarch;
in
builtins.listToAttrs (darwinConfigurationAttrs "aarch64-darwin");
in {
inherit nixosConfigurations;
inherit darwinConfigurations;
};
lib = {
inherit defineSystems;
};
in
lib