about summary refs log tree commit diff
path: root/perl/lib/Nix
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2012-11-23T15·20+0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2012-11-23T15·20+0100
commita3d6585c5a1006d4f9ebd2163d06f86ab71a4a3e (patch)
tree9e6cb9a904d0c93f825af28c43c319666121da2d /perl/lib/Nix
parent9de6bc5d05027363f968c20e53e8c3d5aa34f8b4 (diff)
nix-copy-closure: Add flag ‘--use-substitutes’
Diffstat (limited to 'perl/lib/Nix')
-rw-r--r--perl/lib/Nix/CopyClosure.pm9
1 files changed, 8 insertions, 1 deletions
diff --git a/perl/lib/Nix/CopyClosure.pm b/perl/lib/Nix/CopyClosure.pm
index 79c6dfcccbf4..931057e9f82b 100644
--- a/perl/lib/Nix/CopyClosure.pm
+++ b/perl/lib/Nix/CopyClosure.pm
@@ -6,7 +6,8 @@ use Nix::Store;
 
 
 sub copyTo {
-    my ($sshHost, $sshOpts, $storePaths, $compressor, $decompressor, $includeOutputs, $dryRun, $sign, $progressViewer) = @_;
+    my ($sshHost, $sshOpts, $storePaths, $compressor, $decompressor,
+        $includeOutputs, $dryRun, $sign, $progressViewer, $useSubstitutes) = @_;
 
     $compressor = "$compressor |" if $compressor ne "";
     $decompressor = "$decompressor |" if $decompressor ne "";
@@ -16,6 +17,12 @@ sub copyTo {
     my @closure = reverse(topoSortPaths(computeFSClosure(0, $includeOutputs,
         map { followLinksToStorePath $_ } @{$storePaths})));
 
+    # Optionally use substitutes on the remote host.
+    if (!$dryRun && $useSubstitutes) {
+        system "ssh $sshHost @{$sshOpts} nix-store -r --ignore-unknown @closure";
+        # Ignore exit status because this is just an optimisation.
+    }
+
     # Ask the remote host which paths are invalid.  Because of limits
     # to the command line length, do this in chunks.  Eventually,
     # we'll want to use ‘--from-stdin’, but we can't rely on the