From 4a91cfd32b44fede17f135b47ff0f035652f203e Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 19 Feb 2014 19:00:51 +0100 Subject: Add a global variable ‘inNixShell’ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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). --- lib/trivial.nix | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/trivial.nix') 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"; + } -- cgit 1.4.1