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: unset IN_NIX_SHELL for nested nix commands #2797

Closed
wants to merge 2 commits into from

Conversation

LnL7
Copy link
Member

@LnL7 LnL7 commented May 10, 2019

This fixes the unexpected behaviour of lib.inNixShell from nixpkgs. With this it only evaluates to true if the current command is nix-shell.

@edolstra
Copy link
Member

Maybe it's simpler to make builtins.getEnv return an empty string for IN_NIX_SHELL?

@LnL7
Copy link
Member Author

LnL7 commented May 10, 2019

That would break the lib function completely, it assumes builtins.getEnv does return something when nix-shell is called.

https://github.com/NixOS/nixpkgs/blob/b246b3211964843bca04b0a2a8580247918da6c7/lib/trivial.nix#L169

It's used like this frequently in by the haskell infrastructure, instead of using a shell.nix and default.nix.

{ pkgs ? import <nixpkgs> {} }:

let
  package = ...;
in
  if pkgs.lib.inNixShell then packge.env else package

@LnL7
Copy link
Member Author

LnL7 commented Jul 3, 2019

Is this usage something that should be fixed or do you prefer providing an alternative like a builtin instead (#2796 (comment))?

@roberth roberth mentioned this pull request Oct 13, 2019
@LnL7
Copy link
Member Author

LnL7 commented Oct 27, 2019

I prefer the idea of #3168 over using a magical environment variable.

@LnL7 LnL7 closed this Oct 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants