nix-helpers: e00c9c7c266898f68b57d52bea95d19095a4517c
1: # Takes a directory path, returns any immediate children in that directory which
2: # are themselves directories, and contain a file with the given name
3: # ('default.nix' by default). Result is an attrset where names are the
4: # subdirectory names, e.g. "subdir", and values are full paths to the contained
5: # file, e.g. "${dir}/subdir/default.nix".
6: #
7: # Note that this is used to bootstrap nix-helpers, so it should work standalone.
8: { }:
9:
10: { dir, filename ? "default.nix" }:
11: with rec {
12: inherit (builtins) attrNames filter getAttr hasAttr listToAttrs readDir;
13:
14: subdirs = filter hasFile (attrNames entries);
15:
16: entries = readDir dir;
17:
18: hasFile = name:
19: (getAttr name entries == "directory")
20: && (hasAttr filename (readDir (dir + "/${name}")));
21:
22: output = name: {
23: inherit name;
24: value = dir + "/${name}/${filename}";
25: };
26:
27: };
28: listToAttrs (map output subdirs)
Generated by git2html.