summary refs log tree commit diff stats
path: root/by-name-overlay.nix
diff options
context:
space:
mode:
Diffstat (limited to 'by-name-overlay.nix')
-rw-r--r--by-name-overlay.nix15
1 files changed, 7 insertions, 8 deletions
diff --git a/by-name-overlay.nix b/by-name-overlay.nix
index 0395492..b52d81a 100644
--- a/by-name-overlay.nix
+++ b/by-name-overlay.nix
@@ -81,8 +81,8 @@ assert fileRegex == null -> fileName != null; let
       else namesForElementDirect shard type;
 
     # Type: String -> String -> ListOf Path
-    mkPath = name: toplevelType: let
-      rawPath = baseDirectory + "/${name}";
+    mkPath = shard: name: toplevelType: let
+      rawPath = baseDirectory + "/${shard}/${name}";
       paths = filterAttrs (_: v: v != null) (mapAttrs' (name: value:
         if builtins.match finalFileRegex name != null
         then nameValuePair name value
@@ -106,15 +106,14 @@ assert fileRegex == null -> fileName != null; let
       then warn "'${fileDisplay}' did not match anything in ${rawPath}. Skipped" [null]
       else mapAttrsToList checkPath paths;
 
+    filterNull = list: builtins.filter (value: value != null) list;
     # Type: String -> String -> AttrSet
-    namesForElementShard = shard: _type:
-      filterAttrs (name: value: value != null)
-      (builtins.mapAttrs
-        mkPath
-        (builtins.readDir (baseDirectory + "/${shard}")));
+    namesForElementShard = shard: _type: (builtins.mapAttrs
+      (name: type: filterNull (mkPath shard name type))
+      (builtins.readDir (baseDirectory + "/${shard}")));
 
     # Type: String -> String -> AttrSet
-    namesForElementDirect = name: type: {"${name}" = builtins.filter (value: value != null) (mkPath name type);};
+    namesForElementDirect = name: type: {"${name}" = filterNull ((mkPath ".") name type);};
 
     # A list of all paths.
     files = flattenAttrs (mapAttrsToList namesForShard (builtins.readDir baseDirectory));