about summary refs log tree commit diff
path: root/scripts/nix-build.in
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/nix-build.in')
-rwxr-xr-xscripts/nix-build.in16
1 files changed, 9 insertions, 7 deletions
diff --git a/scripts/nix-build.in b/scripts/nix-build.in
index 899882952b12..a7f23df41a1d 100755
--- a/scripts/nix-build.in
+++ b/scripts/nix-build.in
@@ -9,7 +9,7 @@ use File::Temp qw(tempdir);
 
 my $dryRun = 0;
 my $verbose = 0;
-my $runEnv = 0;
+my $runEnv = $0 =~ /nix-shell$/;
 my $pure = 0;
 
 my @instArgs = ();
@@ -20,8 +20,10 @@ my $shell = $ENV{SHELL} || "/bin/sh";
 my $envCommand = ""; # interactive shell
 my @envExclude = ();
 
+my $myName = $runEnv ? "nix-shell" : "nix-build";
 
-my $tmpDir = tempdir("nix-build.XXXXXX", CLEANUP => 1, TMPDIR => 1)
+
+my $tmpDir = tempdir("$myName.XXXXXX", CLEANUP => 1, TMPDIR => 1)
     or die "cannot create a temporary directory";
 
 my $outLink = "./result";
@@ -35,11 +37,11 @@ for (my $n = 0; $n < scalar @ARGV; $n++) {
     my $arg = $ARGV[$n];
 
     if ($arg eq "--help") {
-        exec "man nix-build" or die;
+        exec "man $myName" or die;
     }
 
     elsif ($arg eq "--version") {
-        print "nix-build (Nix) $Nix::Config::version\n";
+        print "$myName (Nix) $Nix::Config::version\n";
         exit 0;
     }
 
@@ -119,7 +121,7 @@ for (my $n = 0; $n < scalar @ARGV; $n++) {
         push @instArgs, $arg;
     }
 
-    elsif ($arg eq "--run-env") {
+    elsif ($arg eq "--run-env") { # obsolete
         $runEnv = 1;
     }
 
@@ -164,7 +166,7 @@ foreach my $expr (@exprs) {
     }
 
     if ($runEnv) {
-        die "$0: ‘--run-env’ requires a single derivation\n" if scalar @drvPaths != 1;
+        die "$0: a single derivation is required\n" if scalar @drvPaths != 1;
         my $drvPath = readlink $drvPaths[0] or die "cannot read symlink `$drvPaths[0]'";
         my $drv = derivationFromPath($drvPath);
 
@@ -197,7 +199,7 @@ foreach my $expr (@exprs) {
             '[ -e $stdenv/setup ] && source $stdenv/setup; ' .
             ($pure ? '' : 'PATH=$PATH:$p; ') .
             'set +e; ' .
-            'PS1="\n\[\033[1;32m\][nix-build:\w]$\[\033[0m\] "; ' .
+            'PS1="\n\[\033[1;32m\][nix-shell:\w]$\[\033[0m\] "; ' .
             $envCommand);
         exec($ENV{NIX_BUILD_SHELL} // "bash", "--rcfile", $rcfile);
         die;