diff options
| author | tv <tv@krebsco.de> | 2018-11-30 09:40:53 +0100 | 
|---|---|---|
| committer | tv <tv@krebsco.de> | 2018-11-30 09:47:26 +0100 | 
| commit | 498668488f801d6accb7d7937f958eecc3135ac3 (patch) | |
| tree | 6626c9abb3b336eb4f6161d22d516080ec4eb6a9 /lib | |
| parent | 8d87e4b8909adff80f9b9dd83fe177a3dff8918d (diff) | |
lib: add mapNixDir{,1}
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/default.nix | 17 | 
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/default.nix b/lib/default.nix index a40225c..7b964b2 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -44,6 +44,23 @@ let      indent = replaceChars ["\n"] ["\n  "]; +    mapNixDir = f: x: { +      list = foldl' mergeAttrs {} (map (mapNixDir1 f) x); +      path = mapNixDir1 f x; +    }.${typeOf x}; + +    mapNixDir1 = f: dirPath: +      listToAttrs +        (map +          (relPath: let +            name = removeSuffix ".nix" relPath; +            path = dirPath + "/${relPath}"; +          in +            nameValuePair name (f path)) +          (filter +            (name: name != "default.nix" && !hasPrefix "." name) +            (attrNames (readDir dirPath)))); +      # https://tools.ietf.org/html/rfc5952      normalize-ip6-addr =        let  | 
