lib.mapNixDir1: prefix names starting with a digit

This commit is contained in:
tv 2020-10-15 14:38:36 +02:00
parent 83bcb46ce9
commit acdb2bea87

View File

@ -60,13 +60,17 @@ let
}.${typeOf x}; }.${typeOf x};
mapNixDir1 = f: dirPath: mapNixDir1 = f: dirPath:
let
toPackageName = name:
if test "^[0-9].*" name then "_${name}" else name;
in
listToAttrs listToAttrs
(map (map
(relPath: let (relPath: let
name = removeSuffix ".nix" relPath; name = removeSuffix ".nix" relPath;
path = dirPath + "/${relPath}"; path = dirPath + "/${relPath}";
in in
nameValuePair name (f path)) nameValuePair (toPackageName name) (f path))
(filter (filter
(name: name != "default.nix" && !hasPrefix "." name) (name: name != "default.nix" && !hasPrefix "." name)
(attrNames (readDir dirPath)))); (attrNames (readDir dirPath))));