diff --git a/checkmate/modules/tests/aspect_provides_functor.nix b/checkmate/modules/tests/aspect_provides_functor.nix new file mode 100644 index 0000000..a0ac277 --- /dev/null +++ b/checkmate/modules/tests/aspect_provides_functor.nix @@ -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; + }; +} diff --git a/nix/types.nix b/nix/types.nix index 13768d4..7687391 100644 --- a/nix/types.nix +++ b/nix/types.nix @@ -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;