Rename ‘nix-build --run-env’ to ‘nix-shell’

This commit is contained in:
Eelco Dolstra 2013-07-19 12:02:44 +02:00
parent dc5f2e7da6
commit 2bc5de8635
7 changed files with 201 additions and 92 deletions

View file

@ -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;