nix-shell: Support a .drv as argument

Fixes #161.
This commit is contained in:
Eelco Dolstra 2013-09-06 14:58:05 +02:00
parent 2c1ecf8e81
commit 5904262640

View file

@ -157,6 +157,7 @@ foreach my $expr (@exprs) {
# Instantiate. # Instantiate.
my @drvPaths; my @drvPaths;
if ($expr !~ /^\/.*\.drv$/) {
# !!! would prefer the perl 5.8.0 pipe open feature here. # !!! would prefer the perl 5.8.0 pipe open feature here.
my $pid = open(DRVPATHS, "-|") || exec "$Nix::Config::binDir/nix-instantiate", "--add-root", $drvLink, "--indirect", @instArgs, $expr; my $pid = open(DRVPATHS, "-|") || exec "$Nix::Config::binDir/nix-instantiate", "--add-root", $drvLink, "--indirect", @instArgs, $expr;
while (<DRVPATHS>) {chomp; push @drvPaths, $_;} while (<DRVPATHS>) {chomp; push @drvPaths, $_;}
@ -164,10 +165,14 @@ foreach my $expr (@exprs) {
die "nix-instantiate killed by signal " . ($? & 127) . "\n" if ($? & 127); die "nix-instantiate killed by signal " . ($? & 127) . "\n" if ($? & 127);
exit 1; exit 1;
} }
} else {
push @drvPaths, $expr;
}
if ($runEnv) { if ($runEnv) {
die "$0: a single derivation is required\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 $drvPath = $drvPaths[0];
$drvPath = readlink $drvPath or die "cannot read symlink `$drvPath'" if -l $drvPath;
my $drv = derivationFromPath($drvPath); my $drv = derivationFromPath($drvPath);
# Build or fetch all dependencies of the derivation. # Build or fetch all dependencies of the derivation.
@ -235,7 +240,7 @@ foreach my $expr (@exprs) {
# Build. # Build.
my @outPaths; my @outPaths;
$pid = open(OUTPATHS, "-|") || exec "$Nix::Config::binDir/nix-store", "--add-root", $outLink, "--indirect", "-r", my $pid = open(OUTPATHS, "-|") || exec "$Nix::Config::binDir/nix-store", "--add-root", $outLink, "--indirect", "-r",
@buildArgs, @drvPaths2; @buildArgs, @drvPaths2;
while (<OUTPATHS>) {chomp; push @outPaths, $_;} while (<OUTPATHS>) {chomp; push @outPaths, $_;}
if (!close OUTPATHS) { if (!close OUTPATHS) {