diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2012-11-23T15·20+0100 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2012-11-23T15·20+0100 |
commit | a3d6585c5a1006d4f9ebd2163d06f86ab71a4a3e (patch) | |
tree | 9e6cb9a904d0c93f825af28c43c319666121da2d /scripts | |
parent | 9de6bc5d05027363f968c20e53e8c3d5aa34f8b4 (diff) |
nix-copy-closure: Add flag ‘--use-substitutes’
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/nix-copy-closure.in | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/scripts/nix-copy-closure.in b/scripts/nix-copy-closure.in index 0eb7a4ed0c16..1a1684ed00ac 100755 --- a/scripts/nix-copy-closure.in +++ b/scripts/nix-copy-closure.in @@ -17,19 +17,14 @@ EOF # Get the target host. my $sshHost; - my $sign = 0; - my $compressor = ""; my $decompressor = ""; - my $progressViewer = ""; - my $toMode = 1; - my $includeOutputs = 0; - my $dryRun = 0; +my $useSubstitutes = 0; # !!! Copied from nix-pack-closure, should put this in a module. @@ -71,6 +66,9 @@ while (@ARGV) { elsif ($arg eq "--dry-run") { $dryRun = 1; } + elsif ($arg eq "--use-substitutes" || $arg eq "-s") { + $useSubstitutes = 1; + } elsif (!defined $sshHost) { $sshHost = $arg; } @@ -84,7 +82,9 @@ openSSHConnection $sshHost or die "$0: unable to start SSH\n"; if ($toMode) { # Copy TO the remote machine. - Nix::CopyClosure::copyTo($sshHost, [ @sshOpts ], [ @storePaths ], $compressor, $decompressor, $includeOutputs, $dryRun, $sign, $progressViewer); + Nix::CopyClosure::copyTo( + $sshHost, [ @sshOpts ], [ @storePaths ], $compressor, $decompressor, + $includeOutputs, $dryRun, $sign, $progressViewer, $useSubstitutes); } else { # Copy FROM the remote machine. @@ -107,10 +107,13 @@ else { # Copy FROM the remote machine. # Export the store paths on the remote machine and import them locally. if (scalar @missing > 0) { print STDERR "copying ", scalar @missing, " missing paths from ‘$sshHost’...\n"; - $compressor = "| $compressor" if $compressor ne ""; - $decompressor = "$decompressor |" if $decompressor ne ""; - $progressViewer = "$progressViewer |" if $progressViewer ne ""; unless ($dryRun) { + if ($useSubstitutes) { + system "$Nix::Config::binDir/nix-store -r --ignore-unknown @missing"; + } + $compressor = "| $compressor" if $compressor ne ""; + $decompressor = "$decompressor |" if $decompressor ne ""; + $progressViewer = "$progressViewer |" if $progressViewer ne ""; my $extraOpts = $sign ? "--sign" : ""; system("set -f; ssh $sshHost @sshOpts 'nix-store --export $extraOpts @missing $compressor' | $progressViewer $decompressor $Nix::Config::binDir/nix-store --import > /dev/null") == 0 or die "copying store paths from remote machine `$sshHost' failed: $?"; |