Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Got infinite recursion encountered when accessing self.outPath in a flake #8300

Closed
Atry opened this issue May 7, 2023 · 1 comment
Closed
Labels

Comments

@Atry
Copy link
Contributor

Atry commented May 7, 2023

Describe the bug

When accessing self.outPath in flake outputs function body, I got infinite recursion encountered.
Steps To Reproduce

  1. create the following flake.nix
    {
      outputs = { self, ... }: builtins.trace self.outPath {
        packages = {};
      };
    }
  2. nix flake show
  3. Error error: infinite recursion encountered

Expected behavior

No error

nix-env --version output

nix-env (Nix) 2.15.0

Additional context

Workaround:

{
  outputs = { self, ... }: {
    packages = builtins.trace self.outPath {};
  };
}

nix flake show works as expected.

Priorities

Add 👍 to issues you find important.

@Atry Atry added the bug label May 7, 2023
@Atry Atry changed the title Got infinite recursion encountered when accessing self.outPath in a flake Got infinite recursion encountered when accessing self.outPath in a flake May 7, 2023
@roberth
Copy link
Member

roberth commented May 7, 2023

This can be further reduced to

# simplified
let
callFlakeOutputs = f:
  let
    self = outputs // sourceInfo;
    outputs = f { inherit self; };
  in
    self;
sourceInfo = { outPath = ./.; };

in
callFlakeOutputs ({ self, ... }: builtins.trace self.outPath {
  foo = true;
})

which then reduces to

let self = builtins.trace self.outPath { } // { outPath = ./.; }; in self

where you can see that in order to evaluate self, we first have to pull outPath from self, which can't be done yet.

This could be solved by

I'll close this as a duplicate of

@roberth roberth closed this as completed May 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants