From 251891d1089c6ff18e3a89b5bfd12efbe0001ab7 Mon Sep 17 00:00:00 2001 From: musjj <72612857+musjj@users.noreply.github.com> Date: Mon, 2 Mar 2026 00:48:35 +0700 Subject: [PATCH 1/2] improve heuristic for detecting if curried This adds a check that ensures it is either a native function or an attribute set that only has __functor and/or __functionArgs attributes --- nix/types.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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; From aa3cdf0ce3511eee3d3da55706d1e41cd2e71517 Mon Sep 17 00:00:00 2001 From: musjj <72612857+musjj@users.noreply.github.com> Date: Mon, 2 Mar 2026 02:15:55 +0700 Subject: [PATCH 2/2] add tests for provides with functors --- .../modules/tests/aspect_provides_functor.nix | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 checkmate/modules/tests/aspect_provides_functor.nix 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; + }; +}