diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2012-10-17 17:01:23 -0400 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2012-10-17 17:01:23 -0400 |
commit | c8daeba30328c83328b632f8f45920d85d7d1968 (patch) | |
tree | 4503e73cfffa0b2c024413b2151647400c0e788e | |
parent | 167e36a5c3127da63d120d9fdaf5e046b829f287 (diff) |
nix-push: Add ‘--link’ flag
If ‘--link’ is given, nix-push will create hard links to the NAR files
in the store, rather than copying them. This is faster and requires
less disk space. However, it doesn't work if the store is on a
different file system.
-rwxr-xr-x | scripts/nix-push.in | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/scripts/nix-push.in b/scripts/nix-push.in index 4a88a3a17..a08a9bca4 100755 --- a/scripts/nix-push.in +++ b/scripts/nix-push.in @@ -23,6 +23,7 @@ my $force = 0; my $destDir; my $writeManifest = 0; my $archivesURL; +my $link = 0; my @roots; for (my $n = 0; $n < scalar @ARGV; $n++) { @@ -45,6 +46,8 @@ for (my $n = 0; $n < scalar @ARGV; $n++) { $n++; die "$0: `$arg' requires an argument\n" unless $n < scalar @ARGV; $archivesURL = $ARGV[$n]; + } elsif ($arg eq "--link") { + $link = 1; } elsif (substr($arg, 0, 1) eq "-") { die "$0: unknown flag `$arg'\n"; } else { @@ -209,7 +212,11 @@ for (my $n = 0; $n < scalar @storePaths2; $n++) { my $dst = "$destDir/$narName"; if (! -f $dst) { my $tmp = "$destDir/.tmp.$$.$narName"; - copy($narFile, $tmp) or die "cannot copy $narFile to $tmp: $!\n"; + if ($link) { + link($narFile, $tmp) or die "cannot link $tmp to $narFile: $!\n"; + } else { + copy($narFile, $tmp) or die "cannot copy $narFile to $tmp: $!\n"; + } rename($tmp, $dst) or die "cannot rename $tmp to $dst: $!\n"; } |