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

Can't eta-reduce with flakes: expected a function but got a thunk #4384

Closed
lovesegfault opened this issue Dec 20, 2020 · 2 comments
Closed
Labels

Comments

@lovesegfault
Copy link
Member

Describe the bug

I have a flake.nix file, in which I moved the outputs into their own output.nix file.

If I try to eta-reduce the outputs = args: import ./output.nix args; call to simply be outputs = import output.nix; I get the following error:

❯ nix flake check
warning: Git tree '/home/bemeurer/src/nix-config' is dirty
error: --- Error ----------------------------------------------------------------------------------------------------------------------------------------- nix
expected a function but got a thunk at /nix/store/h21gfgrkjkhwl0f1ri2jhaqsdssrzm86-source/flake.nix:29:3

Steps To Reproduce

  1. mkdir flake-bug && cd flake-bug
  2. echo "{ inputs = { }; outputs = import ./outputs.nix; }" > flake.nix
  3. echo "{ ... }: { }"> outputs.nix
  4. nix flake check
  5. See error

Expected behavior

I expected the thunk to be forced and understood by nix to be a function.

nix-env --version output
nix-env (Nix) 2.4pre20201201_5a6ddb3

@andir
Copy link
Member

andir commented Dec 20, 2020

Probably a duplicate of #3966 ?

@edolstra
Copy link
Member

Right, it's not allowed to have any evaluation to get the outputs function. This is because the arguments to outputs can specify flake inputs (e.g. { nixpkgs }: ...).

ambroisie added a commit to ambroisie/nix-config that referenced this issue May 3, 2023
This ends up being more annoying than useful most of the time anyway...

Make a note that we can't just eta-reduce the outputs, due to a nix
limitation on flake outputs (see [1]).

[1]: NixOS/nix#4384
ambroisie added a commit to ambroisie/nix-config that referenced this issue May 3, 2023
This ends up being more annoying than useful most of the time anyway...

Make a note that we can't just eta-reduce the outputs, due to a nix
limitation on flake outputs (see [1]).

[1]: NixOS/nix#4384
ambroisie added a commit to ambroisie/nix-config that referenced this issue May 3, 2023
This ends up being more annoying than useful most of the time anyway...

Make a note that we can't just eta-reduce the outputs, due to a nix
limitation on flake outputs (see [1]).

[1]: NixOS/nix#4384
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

3 participants