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
4 changes: 2 additions & 2 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ ci:
just test

fmt *args:
nix run github:denful/checkmate#fmt --override-input target path:. {{args}}
nix run github:denful/checkmate#fmt --override-input target path:. -L {{args}}

test *args:
nix flake check github:denful/checkmate --override-input target . {{args}}
nix flake check github:denful/checkmate --override-input target . -L {{args}}

5 changes: 5 additions & 0 deletions checkmate/modules/tests.nix
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,11 @@ in
}).config.foo;
expected = 22;
};

combinator."test combinator syntax to compose import-tree" = {
expr = it (it: it.withLib lib) (it: it.leafs) ../tree/_scoped;
expected = [ ../tree/_scoped/foo.nix ];
};
};

}
Expand Down
29 changes: 18 additions & 11 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,21 @@ let
# module exists so we delay access to lib til we are part of the module system.
module =
{ lib, ... }:
let
files = leafs lib path;
imports = if scoped == { } then files else map scoped-import files;
in
{
imports = (if scoped == { } then leafs else scoped-leafs) lib path;
inherit imports;
};

scoped-leafs =
lib: root:
map (builtins.scopedImport (
{
inherit builtins;
__nixPath = [ ];
}
// scoped
)) (leafs lib root);
scoped-import = builtins.scopedImport (
{
inherit builtins;
__nixPath = [ ];
}
// scoped
);

leafs =
lib:
Expand Down Expand Up @@ -145,7 +147,12 @@ let

inModuleEval = and (x: x ? options) builtins.isAttrs;

functor = self: arg: perform self.__config (if inModuleEval arg then [ ] else arg);
functor =
self: arg:
if builtins.isFunction arg && builtins.functionArgs arg == { } then
arg self # arg is a combinator pass the self import-tree obj
else
perform self.__config (if inModuleEval arg then [ ] else arg);

callable =
let
Expand Down