about summary refs log tree commit diff
path: root/scripts
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2014-08-13T21·16+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2014-08-13T21·16+0200
commit3e5dbb24337d8416cfe46484eb2692811546a9c1 (patch)
tree491de5e851e446bed37cc78b7c807edb28a76f00 /scripts
parent3bea429ae8190565978104db3dbbb5e1a53fc018 (diff)
nix-shell: Use $XDG_RUNTIME_DIR
This prevents collisions with other users.

Fixes #262.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/nix-build.in3
1 files changed, 2 insertions, 1 deletions
diff --git a/scripts/nix-build.in b/scripts/nix-build.in
index cf7efa891949..ef86cb97b7ce 100755
--- a/scripts/nix-build.in
+++ b/scripts/nix-build.in
@@ -204,6 +204,7 @@ foreach my $expr (@exprs) {
             or die "$0: failed to build all dependencies\n";
 
         # Set the environment.
+        my $tmp = $ENV{"TMPDIR"} // $ENV{"XDG_RUNTIME_DIR"} // "/tmp";
         if ($pure) {
             foreach my $name (keys %ENV) {
                 next if grep { $_ eq $name } ("HOME", "USER", "LOGNAME", "DISPLAY", "PATH", "TERM", "IN_NIX_SHELL", "TZ", "PAGER");
@@ -212,7 +213,7 @@ foreach my $expr (@exprs) {
             # NixOS hack: prevent /etc/bashrc from sourcing /etc/profile.
             $ENV{'__ETC_PROFILE_SOURCED'} = 1;
         }
-        $ENV{'NIX_BUILD_TOP'} = $ENV{'TMPDIR'} = $ENV{'TEMPDIR'} = $ENV{'TMP'} = $ENV{'TEMP'} = $ENV{'TMPDIR'} // "/tmp";
+        $ENV{'NIX_BUILD_TOP'} = $ENV{'TMPDIR'} = $ENV{'TEMPDIR'} = $ENV{'TMP'} = $ENV{'TEMP'} = $tmp;
         $ENV{'NIX_STORE'} = $Nix::Config::storeDir;
         $ENV{$_} = $drv->{env}->{$_} foreach keys %{$drv->{env}};