Skip to content

BUG: Exported providers lose function argument reflection #352

@DylanRJohnston

Description

@DylanRJohnston

Description

Providers exported through a namespace lose their function argument reflection upon import breaking ctx invocation (they get called with {class, aspect-chain} because aspect resolution thinks they're static aspects). You can see the divergence in behaviour of namespace exported providers between test-internal-exported-providers-function-arg-reflection and test-external-exported-providers-function-arg-reflection where the later fails with { }. I wasn't sure how best to simulate a namespace import in a test so I went the perhaps overkill method of using inputs.nixpkgs.lib.evalModules.

{ denTest, ... }:
{
  flake.tests.deadbugs-issue-xxx =
    let
      module =
        { inputs, ... }:
        {
          imports = [
            inputs.den.flakeModule
            (inputs.den.namespace "test" true)
          ];

          test.aspect._.host =
            { host, ... }:
            {
              nixos.environment.sessionVariables.TEST_HOST = host.name;
            };
        };
      internal = module;
      external =
        inputs:
        (inputs.nixpkgs.lib.evalModules {
          specialArgs = { inherit inputs; };
          modules = [ module ];
        }).config.flake;
    in
    {
      test-internal-exported-providers-function-arg-reflection = denTest (
        {
          lib,
          test,
          ...
        }:
        {
          imports = [ internal ];

          expr = lib.functionArgs test.aspect._.host;
          expected = {
            host = false;
          };
        }
      );

      test-raw-exported-providers-function-arg-reflection = denTest (
        {
          inputs,
          lib,
          test,
          ...
        }:
        {
          expr = lib.functionArgs (external inputs).denful.test.aspect._.host;
          expected = {
            host = false;
          };
        }
      );

      test-external-exported-providers-function-arg-reflection = denTest (
        {
          inputs,
          lib,
          test,
          ...
        }:

        {
          imports = [ (inputs.den.namespace "test" [ (external inputs) ]) ];
          expr = lib.functionArgs test.aspect._.host;
          expected = {
            host = false;
          };
        }
      );
    };
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions