]> Git — Sourcephile - sourcephile-nix.git/blob - overlays/lib/filesystem.nix
nix: revamp the hierarchy (again)
[sourcephile-nix.git] / overlays / lib / filesystem.nix
1 self: super:
2 let lib = super.lib; in
3 {
4 lib = (super.lib or {}) // {
5 findFiles = pattern:
6 with builtins;
7 let go = curr:
8 let dir = readDir curr; in
9 let files = lib.filterAttrs (name: type:
10 type == "regular" &&
11 match pattern name != null) dir; in
12 let dirs = lib.filterAttrs (name: type: type == "directory") dir; in
13 map (name: "${curr}/${name}") (attrNames files) ++
14 lib.concatMap (name: go "${curr}/${name}") (attrNames dirs)
15 ;
16 in root: go (toPath root);
17 };
18 }