From c8daeba30328c83328b632f8f45920d85d7d1968 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 17 Oct 2012 17:01:23 -0400 Subject: [PATCH] =?UTF-8?q?nix-push:=20Add=20=E2=80=98--link=E2=80=99=20fl?= =?UTF-8?q?ag?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- scripts/nix-push.in | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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"; }