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

nix-shell breaks with an eval-error in nixpkgs with Nix 3.0pre #4003

Closed
Ma27 opened this issue Sep 10, 2020 · 4 comments
Closed

nix-shell breaks with an eval-error in nixpkgs with Nix 3.0pre #4003

Ma27 opened this issue Sep 10, 2020 · 4 comments

Comments

@Ma27
Copy link
Member

Ma27 commented Sep 10, 2020

Describe the bug

Running nix-shell on any nixpkgs checkout (checked on 1d60af77224f25a0c428b21a34463ed1719caa27) fails with the following error on Nix 3.0:

→ nix-shell -A hello
error: --- TypeError -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- nix-shell
at: (84:1) in file: /home/ma27/Projects/nixpkgs/pkgs/top-level/impure.nix

    83|
    84| import ./. (builtins.removeAttrs args [ "system" "platform" ] // {
      | ^
    85|   inherit config overlays crossSystem crossOverlays;

anonymous function at /home/ma27/Projects/nixpkgs/pkgs/top-level/default.nix:20:1 called with unexpected argument 'inNixShell'

Expected behavior

Getting an open nix-shell.

nix-env --version output

nix-env (Nix) 3.0pre20200829_f156513

Additional context

I didn't have the issue on 2.4pre20200721_ff314f1 and identified 6262007 (from #3965) to be the problem. Reverting this commit on top of 77d4758 fixes the issue.

The patch 6262007 fixes a bug where auto-calling a function a@{ ... }: a is missing all extra-arguments when being called from CLI with nix-instantiate --argstr arg value as the evaluator only added the attributes that were defined in the { ... }-expression.

While this fixes an actual bug, this breaks pkgs/top-level/impure.nix from nixpkgs since this file defines a function with an ellipsis. And all arguments a@{ ... } from this function get passed to pkgs/top-level/default.nix which defines a function without an ellipsis.

Previously everything worked fine since a@{ ... } in impure.nix didn't have the value inNixShell (which gets passed to an expression in a shell.nix since 9d612c3). Since inNixShel isn't defined in the argument-list of pkgs/top-level/default.nix and inNixShell gets passed to this function, the evaluation with nix-shell is breaking now.

I acknowledge that 6262007 fixes an actual bug and shouldn't be reverted. However I'm not so sure what's the best solution for the kind of problem I described in this issue: the easiest fix for nixpkgs would be to remove inNixShell from the attr-set that gets passed to default.nix. However we should document the inNixShell-value at least. Also I'm wondering if we should catch this error and explain that inNixShell is most likely the cause.

cc @edolstra @glittershark

@Ma27 Ma27 added the bug label Sep 10, 2020
@glittershark
Copy link
Member

this kinda seems to me like nixpkgs is relying on incorrect behavior in nix. Could we just add an ellipsis to the function in pkgs/top-level/default.nix? that'd be backwards-compatible with current nix and also future-compatible with #3965

Ma27 added a commit to Ma27/nixpkgs that referenced this issue Sep 11, 2020
For a full description of the underlying issue please read
NixOS/nix#4003
@Ma27
Copy link
Member Author

Ma27 commented Sep 11, 2020

@glittershark that's what I've done in NixOS/nixpkgs#97807. I think that we should document this here as well (and probably catch this kind of error just in case other setups are having it as well now) before closing this issue :)

Ma27 added a commit to NixOS/nixpkgs that referenced this issue Sep 14, 2020
For a full description of the underlying issue please read
NixOS/nix#4003

(cherry picked from commit fa6064a)
Ma27 added a commit to NixOS/nixpkgs that referenced this issue Sep 14, 2020
For a full description of the underlying issue please read
NixOS/nix#4003

(cherry picked from commit fa6064a)
@stale
Copy link

stale bot commented Mar 16, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the stale label Mar 16, 2021
@Ma27
Copy link
Member Author

Ma27 commented Mar 16, 2021

Should be fixed now in nixpkgs.

@Ma27 Ma27 closed this as completed Mar 16, 2021
globin pushed a commit to mayflower/nixpkgs that referenced this issue Aug 25, 2022
For a full description of the underlying issue please read
NixOS/nix#4003

(cherry picked from commit fa6064a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants