mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-10 00:08:07 +02:00
* nix-copy-closure: force a login shell on the remote machine to make
sure that nix-store is in the PATH. * nix-copy-closure: option --gzip to compress data.
This commit is contained in:
parent
4c5e6d1a2f
commit
fa2be32034
1 changed files with 11 additions and 3 deletions
|
@ -15,10 +15,13 @@ EOF
|
|||
|
||||
# Get the target host.
|
||||
my $sshHost = shift @ARGV;
|
||||
my @sshOpts = split ' ', $ENV{"NIX_SSHOPTS"};
|
||||
my @sshOpts = split ' ', ($ENV{"NIX_SSHOPTS"} or "");
|
||||
|
||||
my $sign = 0;
|
||||
|
||||
my $compressor = "cat";
|
||||
my $decompressor = "cat";
|
||||
|
||||
|
||||
# !!! Copied from nix-pack-closure, should put this in a module.
|
||||
my %storePathsSeen;
|
||||
|
@ -30,6 +33,11 @@ while (@ARGV) {
|
|||
$sign = 1;
|
||||
next;
|
||||
}
|
||||
if ($storePath eq "--gzip") {
|
||||
$compressor = "gzip";
|
||||
$decompressor = "gunzip";
|
||||
next;
|
||||
}
|
||||
|
||||
# $storePath might be a symlink to the store, so resolve it.
|
||||
$storePath = (`$binDir/nix-store --query --resolve '$storePath'`
|
||||
|
@ -54,7 +62,7 @@ while (@ARGV) {
|
|||
|
||||
|
||||
# Ask the remote host which paths are invalid.
|
||||
open(READ, "-|", "ssh", @sshOpts, $sshHost, "nix-store", "--check-validity", "--print-invalid", @storePaths);
|
||||
open(READ, "ssh @sshOpts $sshHost sh --login -c '\"nix-store --check-validity --print-invalid @storePaths\"'|");
|
||||
my @missing = ();
|
||||
while (<READ>) {
|
||||
chomp;
|
||||
|
@ -68,6 +76,6 @@ close READ or die;
|
|||
if (scalar @missing > 0) {
|
||||
my $extraOpts = "";
|
||||
$extraOpts .= "--sign" if $sign == 1;
|
||||
system("nix-store --export $extraOpts @missing | ssh @sshOpts $sshHost nix-store --import") == 0
|
||||
system("nix-store --export $extraOpts @missing | $compressor | ssh @sshOpts $sshHost sh --login -c '\"$decompressor | nix-store --import\"'") == 0
|
||||
or die "copying store paths to remote machine failed: $?";
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue