Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 1, 2025
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