Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions checkmate.nix
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,23 @@ in
expected = [ ./tree/modules/hello-world/mod.nix ];
};

import-tree."test passes non-paths without string conversion" = {
expr =
let
mod = it [
{
options.hello = lib.mkOption {
default = "world";
type = lib.types.str;
};
}
];
res = lib.modules.evalModules { modules = [ mod ]; };
in
res.config.hello;
expected = "world";
};

import-tree."test can take other import-trees as if they were paths" = {
expr = (lit.filter (lib.hasInfix "mod")).leafs [
(it.addPath ./tree/modules/hello-option)
Expand Down
10 changes: 8 additions & 2 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,21 @@ let
treeFiles x
else if hasOutPath x then
listFilesRecursive x.outPath
else if lib.pathIsDirectory x then
else if isDirectory x then
lib.filesystem.listFilesRecursive x
else
[ x ];
treeFiles = t: (t.withLib lib).leafs.result;
pathFilter = compose (and filterf initialFilter) toString;
filter = x: if isPathLike x then pathFilter x else filterf x;
in
lib.pipe
[ paths root ]
[
(lib.lists.flatten)
(map listFilesRecursive)
(lib.lists.flatten)
(builtins.filter (compose (and filterf initialFilter) toString))
(builtins.filter filter)
(map mapf)
];

Expand All @@ -71,6 +73,10 @@ let
attrs: k: f:
attrs // { ${k} = f attrs.${k}; };

isDirectory = and (x: builtins.readFileType x == "directory") isPathLike;

isPathLike = x: builtins.isPath x || builtins.isString x || hasOutPath x;

hasOutPath = and (x: x ? outPath) builtins.isAttrs;

isImportTree = and (x: x ? __config.__functor) builtins.isAttrs;
Expand Down