diff options
Diffstat (limited to 'scripts/nix-copy-closure.in')
-rw-r--r-- | scripts/nix-copy-closure.in | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/scripts/nix-copy-closure.in b/scripts/nix-copy-closure.in index ec2df8828963..80a6a80518b5 100644 --- a/scripts/nix-copy-closure.in +++ b/scripts/nix-copy-closure.in @@ -4,8 +4,20 @@ my $binDir = $ENV{"NIX_BIN_DIR"}; $binDir = "@bindir@" unless defined $binDir; +if (scalar @ARGV < 1) { + print STDERR <<EOF +Usage: nix-copy-closure HOSTNAME [--sign] PATHS... +EOF + ; + exit 1; +} + + # Get the target host. my $sshHost = shift @ARGV; +my @sshOpts = split ' ', $ENV{"NIX_SSHOPTS"}; + +my $sign = 0; # !!! Copied from nix-pack-closure, should put this in a module. @@ -14,6 +26,10 @@ my @storePaths = (); while (@ARGV) { my $storePath = shift @ARGV; + if ($storePath eq "--sign") { + $sign = 1; + next; + } # $storePath might be a symlink to the store, so resolve it. $storePath = (`$binDir/nix-store --query --resolve '$storePath'` @@ -38,7 +54,7 @@ while (@ARGV) { # Ask the remote host which paths are invalid. -open(READ, "-|", "ssh", $sshHost, "nix-store", "--check-validity", "--print-invalid", @storePaths); +open(READ, "-|", "ssh", @sshOpts, $sshHost, "nix-store", "--check-validity", "--print-invalid", @storePaths); my @missing = (); while (<READ>) { chomp; @@ -50,6 +66,8 @@ close READ or die; # Export the store paths and import them on the remote machine. if (scalar @missing > 0) { - system("nix-store --export @missing | ssh $sshHost nix-store --import") == 0 + my $extraOpts = ""; + $extraOpts .= "--sign" if $sign == 1; + system("nix-store --export $extraOpts @missing | ssh @sshOpts $sshHost nix-store --import") == 0 or die "copying store paths to remote machine failed: $?"; } |