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
33 changes: 33 additions & 0 deletions checkmate/modules/tests/aspect_provides_functor.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
mkFlake,
evalMod,
...
}:
{

flake.tests."test provides with functors" =
let
flake = mkFlake {
flake.aspects =
{ aspects, ... }:
{
aspectOne = {
includes = [ aspects.aspectTwo._.aspectThree._.aspectFour ];
classOne = { };
};
aspectTwo.provides.aspectThree = {
provides.aspectFour.classOne.bar = [ "hello" ];
__functor = self: _: self;
};
};
};

expr = (evalMod "classOne" flake.modules.classOne.aspectOne).bar;
expected = [
"hello"
];
in
builtins.trace expr {
inherit expr expected;
};
}
6 changes: 5 additions & 1 deletion nix/types.nix
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ let
directProviderFn = lib.types.addCheck (lib.types.functionTo aspectSubmodule) isProviderFn;

# Curried provider function: (params) → provider (enables parametrization)
curriedProviderFn = lib.types.functionTo providerType;
curriedProviderFn = lib.types.addCheck (lib.types.functionTo providerType) (
f:
builtins.isFunction f
|| lib.isAttrs f && lib.subtractLists [ "__functor" "__functionArgs" ] (lib.attrNames f) == [ ]
);

# Any provider function: direct or curried
providerFn = lib.types.either directProviderFn curriedProviderFn;
Expand Down