From 5f0b1b803500f468a1d60217cc0fc81bb8fd58aa Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 30 Nov 2018 09:40:53 +0100 Subject: lib: add mapNixDir{,1} --- lib/default.nix | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'lib') diff --git a/lib/default.nix b/lib/default.nix index a40225c4..7b964b22 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 -- cgit v1.2.3