From a3d6585c5a1006d4f9ebd2163d06f86ab71a4a3e Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 23 Nov 2012 16:20:16 +0100 Subject: nix-copy-closure: Add flag ‘--use-substitutes’ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- perl/lib/Nix/CopyClosure.pm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'perl') 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 -- cgit 1.4.1