1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-06 21:41:48 +02:00

nix-push: Only generate and copy a NAR if it doesn't already exist

This prevents unnecessary and slow rebuilds of NARs that already exist
in the binary cache.
This commit is contained in:
Eelco Dolstra 2012-10-17 16:45:04 -04:00
parent ac238d619c
commit 167e36a5c3
6 changed files with 107 additions and 65 deletions

View file

@ -6,6 +6,7 @@ use File::Temp qw(tempdir);
use File::stat;
use Nix::Store;
use Nix::Config;
use Nix::Utils;
my $url = shift;
my $expHash = shift;
@ -20,22 +21,6 @@ EOF
exit 1;
}
sub writeFile {
my ($fn, $s) = @_;
open TMP, ">$fn" or die;
print TMP "$s" or die;
close TMP or die;
}
sub readFile {
local $/ = undef;
my ($fn) = @_;
open TMP, "<$fn" or die;
my $s = <TMP>;
close TMP or die;
return $s;
}
my $tmpDir = tempdir("nix-prefetch-url.XXXXXX", CLEANUP => 1, TMPDIR => 1)
or die "cannot create a temporary directory";