Import all nix files in a directory tree. Discussions: https://oeiuwq.zulipchat.com/join/nqp26cd4kngon6mo3ncgnuap/ dendrix.oeiuwq.com/Dendritic.html
dendritic inputs

fix: dont try to convert attrSets that are not paths. (#16)

authored by oeiuwq.com and committed by

GitHub 7a0649ef e6603e9c

+25 -2
+17
checkmate.nix
··· 203 203 expected = [ ./tree/modules/hello-world/mod.nix ]; 204 204 }; 205 205 206 + import-tree."test passes non-paths without string conversion" = { 207 + expr = 208 + let 209 + mod = it [ 210 + { 211 + options.hello = lib.mkOption { 212 + default = "world"; 213 + type = lib.types.str; 214 + }; 215 + } 216 + ]; 217 + res = lib.modules.evalModules { modules = [ mod ]; }; 218 + in 219 + res.config.hello; 220 + expected = "world"; 221 + }; 222 + 206 223 import-tree."test can take other import-trees as if they were paths" = { 207 224 expr = (lit.filter (lib.hasInfix "mod")).leafs [ 208 225 (it.addPath ./tree/modules/hello-option)
+8 -2
default.nix
··· 35 35 treeFiles x 36 36 else if hasOutPath x then 37 37 listFilesRecursive x.outPath 38 - else if lib.pathIsDirectory x then 38 + else if isDirectory x then 39 39 lib.filesystem.listFilesRecursive x 40 40 else 41 41 [ x ]; 42 42 treeFiles = t: (t.withLib lib).leafs.result; 43 + pathFilter = compose (and filterf initialFilter) toString; 44 + filter = x: if isPathLike x then pathFilter x else filterf x; 43 45 in 44 46 lib.pipe 45 47 [ paths root ] ··· 47 49 (lib.lists.flatten) 48 50 (map listFilesRecursive) 49 51 (lib.lists.flatten) 50 - (builtins.filter (compose (and filterf initialFilter) toString)) 52 + (builtins.filter filter) 51 53 (map mapf) 52 54 ]; 53 55 ··· 70 72 mapAttr = 71 73 attrs: k: f: 72 74 attrs // { ${k} = f attrs.${k}; }; 75 + 76 + isDirectory = and (x: builtins.readFileType x == "directory") isPathLike; 77 + 78 + isPathLike = x: builtins.isPath x || builtins.isString x || hasOutPath x; 73 79 74 80 hasOutPath = and (x: x ? outPath) builtins.isAttrs; 75 81