-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.nix
47 lines (45 loc) · 1.28 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
let
# create list of directories at path
readDirNames = with builtins; path:
let
files = readDir path;
isDirectory = name: (files."${name}" == "directory") && (substring 0 1 name != ".");
in
filter isDirectory (attrNames files);
mkHost = { self, lib, modules, platform, arch }: name:
let
paths = [
./.
./${platform}
./${platform}/${arch}
./${platform}/${arch}/${name}
];
in
{
inherit name;
value = self.inputs.nixpkgs.lib.nixosSystem {
system = "${arch}-${platform}";
modules = modules ++ [
# TODO: not sure why the hostname gets set to `nixos`
({ ... }: { config.networking.hostName = name; })
] ++ (with builtins; filter pathExists (map (path: path + /configuration.nix) paths));
specialArgs = {
hostPath = ./${platform}/${arch}/${name};
flake = self // {
packages = self.outputs.packages."${arch}-${platform}";
};
};
};
};
in
args@{ self, lib, modules }: with builtins;
listToAttrs (concatMap
(platform: concatMap
(arch: map
(mkHost (args // { inherit platform arch; }))
(readDirNames ./${platform}/${arch})
)
(readDirNames ./${platform})
)
(readDirNames ./.)
)