From cdc9b4cdde0fa2b5afde8d360d031a20a2172783 Mon Sep 17 00:00:00 2001 From: Victor Borja Date: Wed, 25 Jun 2025 18:02:19 -0600 Subject: [PATCH 1/4] fix: dont break when given paths that are files. filter on them instead. --- checkmate.nix | 5 +++++ default.nix | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/checkmate.nix b/checkmate.nix index 9fa7954..226790d 100644 --- a/checkmate.nix +++ b/checkmate.nix @@ -138,6 +138,11 @@ in expected = 1; }; + import-tree."test does not breaks if given a path to a file instead of a directory." = { + expr = lit.leafs ./tree/x/y.nix; + expected = [ ./tree/x/y.nix ]; + }; + import-tree."test returns a module with a single imported nested module having leafs" = { expr = let diff --git a/default.nix b/default.nix index fdfc0cc..c742f8c 100644 --- a/default.nix +++ b/default.nix @@ -29,7 +29,14 @@ let lib: root: let initialFilter = andNot (lib.hasInfix "/_") (lib.hasSuffix ".nix"); - listFilesRecursive = x: if isImportTree x then treeFiles x else lib.filesystem.listFilesRecursive x; + listFilesRecursive = + x: + if isImportTree x then + treeFiles x + else if lib.pathIsDirectory x then + lib.filesystem.listFilesRecursive x + else + x; treeFiles = t: (t.withLib lib).leafs.result; in lib.pipe From 4ac0d21d44c0b23c7f08719f9d3f83146731fc09 Mon Sep 17 00:00:00 2001 From: Victor Borja Date: Thu, 26 Jun 2025 00:07:37 +0000 Subject: [PATCH 2/4] Update default.nix Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/default.nix b/default.nix index c742f8c..faf35e0 100644 --- a/default.nix +++ b/default.nix @@ -36,7 +36,7 @@ let else if lib.pathIsDirectory x then lib.filesystem.listFilesRecursive x else - x; + [x]; treeFiles = t: (t.withLib lib).leafs.result; in lib.pipe From 4b373d6a0d8699ea7555e219fdb7f2de163a6a91 Mon Sep 17 00:00:00 2001 From: Victor Borja Date: Thu, 26 Jun 2025 00:07:55 +0000 Subject: [PATCH 3/4] Update checkmate.nix Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- checkmate.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/checkmate.nix b/checkmate.nix index 226790d..45787f2 100644 --- a/checkmate.nix +++ b/checkmate.nix @@ -138,7 +138,7 @@ in expected = 1; }; - import-tree."test does not breaks if given a path to a file instead of a directory." = { + import-tree."test does not break if given a path to a file instead of a directory." = { expr = lit.leafs ./tree/x/y.nix; expected = [ ./tree/x/y.nix ]; }; From 599fc232b494dc754385f4510d6cd707ab162d1f Mon Sep 17 00:00:00 2001 From: Victor Borja Date: Wed, 25 Jun 2025 18:09:52 -0600 Subject: [PATCH 4/4] fmt --- default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/default.nix b/default.nix index faf35e0..ed026b6 100644 --- a/default.nix +++ b/default.nix @@ -36,7 +36,7 @@ let else if lib.pathIsDirectory x then lib.filesystem.listFilesRecursive x else - [x]; + [ x ]; treeFiles = t: (t.withLib lib).leafs.result; in lib.pipe