aboutsummaryrefslogtreecommitdiff
path: root/scripts/nix-copy-closure.in
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/nix-copy-closure.in')
-rwxr-xr-xscripts/nix-copy-closure.in23
1 files changed, 13 insertions, 10 deletions
diff --git a/scripts/nix-copy-closure.in b/scripts/nix-copy-closure.in
index 0eb7a4ed0..1a1684ed0 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: $?";