nix-shell: Set some environment variables also set by build.cc

Setting $NIX_STORE causes the purity checks in gcc/ld-wrapper to kick
in, so that's why we unset $NIX_ENFORCE_PURITY.
This commit is contained in:
Eelco Dolstra 2013-07-19 14:06:58 +02:00
parent 2bc5de8635
commit 48858ad5ca

View file

@ -184,7 +184,8 @@ foreach my $expr (@exprs) {
# NixOS hack: prevent /etc/bashrc from sourcing /etc/profile. # NixOS hack: prevent /etc/bashrc from sourcing /etc/profile.
$ENV{'__ETC_PROFILE_SOURCED'} = 1; $ENV{'__ETC_PROFILE_SOURCED'} = 1;
} }
$ENV{'NIX_BUILD_TOP'} = $ENV{'TMPDIR'} || "/tmp"; $ENV{'NIX_BUILD_TOP'} = $ENV{'TMPDIR'} = $ENV{'TEMPDIR'} = $ENV{'TMP'} = $ENV{'TEMP'} = $ENV{'TMPDIR'} // "/tmp";
$ENV{'NIX_STORE'} = $Nix::Config::storeDir;
$ENV{$_} = $drv->{env}->{$_} foreach keys %{$drv->{env}}; $ENV{$_} = $drv->{env}->{$_} foreach keys %{$drv->{env}};
# Run a shell using the derivation's environment. For # Run a shell using the derivation's environment. For
@ -200,6 +201,7 @@ foreach my $expr (@exprs) {
($pure ? '' : 'PATH=$PATH:$p; ') . ($pure ? '' : 'PATH=$PATH:$p; ') .
'set +e; ' . 'set +e; ' .
'PS1="\n\[\033[1;32m\][nix-shell:\w]$\[\033[0m\] "; ' . 'PS1="\n\[\033[1;32m\][nix-shell:\w]$\[\033[0m\] "; ' .
'unset NIX_ENFORCE_PURITY; ' .
$envCommand); $envCommand);
exec($ENV{NIX_BUILD_SHELL} // "bash", "--rcfile", $rcfile); exec($ENV{NIX_BUILD_SHELL} // "bash", "--rcfile", $rcfile);
die; die;