1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{
lib ? import "${(import ../npins).nixpkgs}/lib",
}:
let
# read the current directorys files and pipe the result through a list of functions
modules = builtins.foldl' (x: f: f x) (builtins.readDir ./.) [
# convert to a list containing just the attribute names
(builtins.attrNames)
# drop "default.nix" from the list
(builtins.filter (name: name != "default.nix"))
(builtins.map (name: {
inherit name;
value = lib.filesystem.listFilesRecursive ./${name};
}))
# convert the resulting list to an attribute set
(builtins.listToAttrs)
];
in
modules
// {
default = lib.flatten (builtins.attrValues modules);
}