]> Git — Sourcephile - sourcephile-nix.git/blob - nixpkgs/overlays/lib/filesystem.nix
mermet: knot: autogeree.net: enable dnssec-signing
[sourcephile-nix.git] / nixpkgs / overlays / lib / filesystem.nix
1 _self: super:
2 with builtins;
3 let lib = super.lib; in
4 {
5 lib = (super.lib or { }) // {
6 loadFile = name: toFile (baseNameOf (toString name)) (readFile name);
7 findFiles = pattern:
8 let
9 go = curr:
10 let dir = readDir curr; in
11 let
12 files = lib.filterAttrs
13 (name: type:
14 type == "regular" &&
15 match pattern name != null)
16 dir;
17 in
18 let dirs = lib.filterAttrs (_name: type: type == "directory") dir; in
19 map (name: "${curr}/${name}") (attrNames files) ++
20 lib.concatMap (name: go "${curr}/${name}") (attrNames dirs)
21 ;
22 in
23 go;
24 };
25 }