nix-shell: Set $IN_NIX_SHELL before evaluation

This has some hacky applications.
This commit is contained in:
Eelco Dolstra 2013-12-20 13:11:41 +01:00
parent 65a6452240
commit 0c1198cf08

View file

@ -175,6 +175,8 @@ foreach my $expr (@exprs) {
$drvPath = readlink $drvPath or die "cannot read symlink `$drvPath'" if -l $drvPath; $drvPath = readlink $drvPath or die "cannot read symlink `$drvPath'" if -l $drvPath;
my $drv = derivationFromPath($drvPath); my $drv = derivationFromPath($drvPath);
$ENV{'IN_NIX_SHELL'} = 1;
# Build or fetch all dependencies of the derivation. # Build or fetch all dependencies of the derivation.
my @inputDrvs = grep { my $x = $_; (grep { $x =~ $_ } @envExclude) == 0 } @{$drv->{inputDrvs}}; my @inputDrvs = grep { my $x = $_; (grep { $x =~ $_ } @envExclude) == 0 } @{$drv->{inputDrvs}};
system("$Nix::Config::binDir/nix-store", "-r", "--no-output", @buildArgs, @inputDrvs, @{$drv->{inputSrcs}}) == 0 system("$Nix::Config::binDir/nix-store", "-r", "--no-output", @buildArgs, @inputDrvs, @{$drv->{inputSrcs}}) == 0
@ -193,8 +195,6 @@ foreach my $expr (@exprs) {
$ENV{'NIX_STORE'} = $Nix::Config::storeDir; $ENV{'NIX_STORE'} = $Nix::Config::storeDir;
$ENV{$_} = $drv->{env}->{$_} foreach keys %{$drv->{env}}; $ENV{$_} = $drv->{env}->{$_} foreach keys %{$drv->{env}};
$ENV{'IN_NIX_SHELL'} = 1;
# Run a shell using the derivation's environment. For # Run a shell using the derivation's environment. For
# convenience, source $stdenv/setup to setup additional # convenience, source $stdenv/setup to setup additional
# environment variables and shell functions. Also don't lose # environment variables and shell functions. Also don't lose