File tree Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change 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 )
Original file line number Diff line number Diff line change 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 ]
46
48
[
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
71
73
attrs : k : f :
72
74
attrs // { ${ k } = f attrs . ${ k } ; } ;
73
75
76
+ isDirectory = and ( x : builtins . readFileType x == "directory" ) isPathLike ;
77
+
78
+ isPathLike = x : builtins . isPath x || builtins . isString x || hasOutPath x ;
79
+
74
80
hasOutPath = and ( x : x ? outPath ) builtins . isAttrs ;
75
81
76
82
isImportTree = and ( x : x ? __config . __functor ) builtins . isAttrs ;
You can’t perform that action at this time.
0 commit comments