summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/pure.nix12
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))));