diff options
author | tv <tv@krebsco.de> | 2024-06-05 18:48:52 +0200 |
---|---|---|
committer | tv <tv@krebsco.de> | 2024-06-05 18:48:52 +0200 |
commit | d68092c6c3caf35beb7cddc51a3f0e962fd8f58b (patch) | |
tree | d14f0e3c39e984e3ee634b43d50b6a3a484e3cb4 /lib | |
parent | 5f09c04951f5c028c7e65f737afbd95808b84992 (diff) |
lib.mapNixDir': init
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pure.nix | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/pure.nix b/lib/pure.nix index 5d4b96b..edf7292 100644 --- a/lib/pure.nix +++ b/lib/pure.nix @@ -82,11 +82,18 @@ let stripAttr = converge (filterAttrsRecursive (n: v: v != {} && v != null)); - mapNixDir = f: x: { + # mapNixDir :: (path -> a) -> listOf path -> listOf a + # mapNixDir :: (path -> a) -> path -> a + mapNixDir = f: mapNixDir' (const f); + + # mapNixDir' :: (str -> path -> a) -> listOf path -> listOf a + # mapNixDir' :: (str -> path -> a) -> path -> a + mapNixDir' = f: x: { list = foldl' mergeAttrs {} (map (mapNixDir1 f) x); path = mapNixDir1 f x; }.${typeOf x}; + # mapNixDir1 :: (str -> path -> a) -> path -> a mapNixDir1 = f: dirPath: let toPackageName = name: @@ -97,8 +104,9 @@ let (relPath: let name = removeSuffix ".nix" relPath; path = dirPath + "/${relPath}"; + pname = toPackageName name; in - nameValuePair (toPackageName name) (f path)) + nameValuePair pname (f pname path)) (attrNames (filterAttrs isNixDirEntry (readDir dirPath)))); |