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

docs: describe $IN_NIX_SHELL values #2796

Merged
merged 1 commit into from May 17, 2019
Merged

Conversation

vcunat
Copy link
Member

@vcunat vcunat commented May 9, 2019

I plan to merge this in a few days if noone reacts (assuming I'll still have the permissions :). Perhaps backport to 2.*-maintenance branches, too.

@@ -14,7 +14,8 @@
<varlistentry><term><envar>IN_NIX_SHELL</envar></term>

<listitem><para>Indicator that tells if the current environment was set up by
<command>nix-shell</command>.</para></listitem>
<command>nix-shell</command>. Since Nix 2.0 the values are
<literal>"pure"</literal> and <literal>"impure"</literal></para></listitem>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(nit) I think the quotes belong outside of the <literal> tags, as the value does not contain the ".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I originally had it without the quotes, but man pages render these as regular words... and that didn't seem sufficient to me.

@matthewbauer
Copy link
Member

There is an issue with IN_NIX_SHELL that should be documented. Basically if you are in a nix-shell and call nix-build, it will still think you are in the nix-shell:

with import <nixpkgs> {};

if lib.inNixShell then builtins.trace "IN_NIX_SHELL" hello else builtins.trace "not IN_NIX_SHELL" hello

This effects haskell a lot.

@LnL7
Copy link
Member

LnL7 commented May 9, 2019

That function is a misuse of IN_NIX_SHELL IMHO. It should probably be replaced by a builtin that actually returns true based on what nix command is invoked or otherwise deprecated.

@vcunat
Copy link
Member Author

vcunat commented May 10, 2019

Regardless of being a misuse (or not), is there any argument against fixing that behavior? (i.e. make nix remove this variable from its env, at least for spawned builders) Some fix of this should be trivial IMO.

@LnL7
Copy link
Member

LnL7 commented May 10, 2019

Hmm, indeed. I thought that wouldn't be possible without changing the semantics, but it looks like that would work.

EDIT #2797

@vcunat vcunat merged commit c0559a1 into NixOS:master May 17, 2019
@vcunat vcunat deleted the p/doc-IN_NIX_SHELL branch May 17, 2019 07:50
vcunat added a commit that referenced this pull request May 17, 2019
See commit 1bffd83

(cherry picked from commit c0559a1)
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

5 participants