summary refs log tree commit diff
path: root/lib/trivial.nix
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2014-02-19 19:00:51 +0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2014-02-19 19:03:16 +0100
commit4a91cfd32b44fede17f135b47ff0f035652f203e (patch)
tree80bb3b0c8c94afaf1caac2d181972fdf35e15167 /lib/trivial.nix
parent484403bf0e229f857cafb67ec2e516ed7dfdc2d2 (diff)
downloadnixlib-4a91cfd32b44fede17f135b47ff0f035652f203e.tar
nixlib-4a91cfd32b44fede17f135b47ff0f035652f203e.tar.gz
nixlib-4a91cfd32b44fede17f135b47ff0f035652f203e.tar.bz2
nixlib-4a91cfd32b44fede17f135b47ff0f035652f203e.tar.lz
nixlib-4a91cfd32b44fede17f135b47ff0f035652f203e.tar.xz
nixlib-4a91cfd32b44fede17f135b47ff0f035652f203e.tar.zst
nixlib-4a91cfd32b44fede17f135b47ff0f035652f203e.zip
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).
Diffstat (limited to 'lib/trivial.nix')
-rw-r--r--lib/trivial.nix3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/trivial.nix b/lib/trivial.nix
index 190cda6abd67..e073da4900cc 100644
--- a/lib/trivial.nix
+++ b/lib/trivial.nix
@@ -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";
+
 }