Add a global variable ‘inNixShell’

This is primarily useful in Nix expressions that are also intended to
be used by nix-shell.  It allows saying things like:

  buildInputs = [ ... ] ++ (if inNixShell then [ emacs ] else [ ]);

This should not be used in Nixpkgs (since the question of what
constitutes a useful nix-shell environment is very subjective).
This commit is contained in:
Eelco Dolstra 2014-02-19 19:00:51 +01:00
parent 484403bf0e
commit 4a91cfd32b

View File

@ -47,4 +47,7 @@ rec {
readFile ../.version
+ (if pathExists suffixFile then readFile suffixFile else "pre-git");
# Whether we're being called by nix-shell. This is useful to
inNixShell = builtins.getEnv "IN_NIX_SHELL" == "1";
}