-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefault.nix
94 lines (87 loc) · 2.79 KB
/
default.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
let
inputs = import ./lon.nix;
inputs_final = inputs;
dnsLib = (import inputs.dns).lib;
lib = (import "${inputs.nixpkgs}/lib").extend (import ./lib inputs_final self.profiles dnsLib);
mkLibForMachine =
machine:
(import "${lib.snowfield.${machine}.nixpkgs_version}/lib").extend (
import ./lib inputs_final self.profiles dnsLib
);
machines_plats = lib.lists.unique (
lib.mapAttrsToList (_name: value: value.arch) (
lib.filterAttrs (_n: v: builtins.hasAttr "arch" v) lib.snowfield
)
);
nixpkgs_plats = builtins.listToAttrs (
builtins.map (plat: {
name = plat;
value = import inputs.nixpkgs { system = plat; };
}) machines_plats
);
self = rec {
nixosModules = builtins.listToAttrs (
map (x: {
name = x;
value = import (./modules + "/${x}");
}) (builtins.attrNames (builtins.readDir ./modules))
);
profiles = builtins.listToAttrs (
map (x: {
name = lib.strings.removeSuffix ".nix" x;
value = import (./profiles + "/${x}");
}) (builtins.attrNames (builtins.readDir ./profiles))
);
nixosConfigurations = builtins.mapAttrs (
name: value:
(lib.mkMachine {
inherit name self dnsLib;
host-config = value;
modules = builtins.attrValues nixosModules ++ lib.snowfield.${name}.profiles;
nixpkgs = lib.snowfield.${name}.nixpkgs_version;
system = lib.snowfield.${name}.arch;
home-manager = lib.snowfield.${name}.hm_version;
})
) (lib.importConfig ./machines);
colmena = {
meta = {
nodeNixpkgs = builtins.mapAttrs (
n: _: import lib.snowfield.${n}.nixpkgs_version
) nixosConfigurations;
nodeSpecialArgs = builtins.mapAttrs (
n: v: v._module.specialArgs // { lib = mkLibForMachine n; }
) nixosConfigurations;
};
} // builtins.mapAttrs (_: v: { imports = v._module.args.modules; }) nixosConfigurations;
packages = builtins.listToAttrs (
builtins.map (plat: {
name = plat;
value =
lib.filterAttrs
(
_name: value:
(
!lib.hasAttrByPath [
"meta"
"platforms"
] value
)
|| builtins.elem plat value.meta.platforms
)
(
builtins.listToAttrs (
builtins.map (e: {
name = e;
value = nixpkgs_plats.${plat}.callPackage (./packages + "/${e}") { };
}) (builtins.attrNames (builtins.readDir ./packages))
)
);
}) machines_plats
);
checks = {
inherit packages;
machines = lib.mapAttrs (_: v: v.config.system.build.toplevel) nixosConfigurations;
};
};
in
self