nix-push: Support -j

Fixes #548.
This commit is contained in:
Eelco Dolstra 2015-06-08 14:16:06 +02:00
parent bf8cc4e9b6
commit f2b67fbf2a

View file

@ -29,6 +29,7 @@ my $archivesURL;
my $link = 0; my $link = 0;
my $secretKeyFile; my $secretKeyFile;
my @roots; my @roots;
my @buildArgs;
for (my $n = 0; $n < scalar @ARGV; $n++) { for (my $n = 0; $n < scalar @ARGV; $n++) {
my $arg = $ARGV[$n]; my $arg = $ARGV[$n];
@ -64,6 +65,10 @@ for (my $n = 0; $n < scalar @ARGV; $n++) {
$n++; $n++;
die "$0: $arg requires an argument\n" unless $n < scalar @ARGV; die "$0: $arg requires an argument\n" unless $n < scalar @ARGV;
$secretKeyFile = $ARGV[$n]; $secretKeyFile = $ARGV[$n];
} elsif ($arg eq "--max-jobs" || $arg eq "-j") {
$n++;
die "$0: $arg requires an argument\n" unless $n < scalar @ARGV;
push @buildArgs, ($arg, $ARGV[$n]);
} elsif (substr($arg, 0, 1) eq "-") { } elsif (substr($arg, 0, 1) eq "-") {
die "$0: unknown flag $arg\n"; die "$0: unknown flag $arg\n";
} else { } else {
@ -153,7 +158,7 @@ close NIX;
# Build the Nix expression. # Build the Nix expression.
print STDERR "building compressed archives...\n"; print STDERR "building compressed archives...\n";
my @narPaths; my @narPaths;
my $pid = open(READ, "$Nix::Config::binDir/nix-build $nixExpr -o $tmpDir/result |") my $pid = open(READ, "-|", "$Nix::Config::binDir/nix-build", $nixExpr, "-o", "$tmpDir/result", @buildArgs)
or die "cannot run nix-build"; or die "cannot run nix-build";
while (<READ>) { while (<READ>) {
chomp; chomp;