tangled
alpha
login
or
join now
tjh.dev
/
nixpkgs
Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
0
fork
atom
overview
issues
pulls
pipelines
copy-tarballs.pl: Use substituters to obtain tarballs
Eelco Dolstra
9 years ago
35bd7708
be8fc331
+29
-12
2 changed files
expand all
collapse all
unified
split
maintainers
scripts
copy-tarballs.pl
find-tarballs.nix
+28
-11
maintainers/scripts/copy-tarballs.pl
···
22
22
use Net::Amazon::S3;
23
23
use Nix::Store;
24
24
25
25
+
isValidPath("/nix/store/foo"); # FIXME: forces Nix::Store initialisation
26
26
+
27
27
+
25
28
# S3 setup.
26
29
my $aws_access_key_id = $ENV{'AWS_ACCESS_KEY_ID'} or die;
27
30
my $aws_secret_access_key = $ENV{'AWS_SECRET_ACCESS_KEY'} or die;
···
127
130
my $url = $fetch->{url};
128
131
my $algo = $fetch->{type};
129
132
my $hash = $fetch->{hash};
133
133
+
my $name = $fetch->{name};
130
134
131
135
if (defined $ENV{DEBUG}) {
132
136
print "$url $algo $hash\n";
···
143
147
next;
144
148
}
145
149
146
146
-
print STDERR "mirroring $url...\n";
150
150
+
my $storePath = makeFixedOutputPath(0, $algo, $hash, $name);
151
151
+
152
152
+
print STDERR "mirroring $url ($storePath)...\n";
147
153
148
154
next if $ENV{DRY_RUN};
149
155
150
150
-
# Download the file using nix-prefetch-url.
151
151
-
$ENV{QUIET} = 1;
152
152
-
$ENV{PRINT_PATH} = 1;
153
153
-
my $fh;
154
154
-
my $pid = open($fh, "-|", "nix-prefetch-url", "--type", $algo, $url, $hash) or die;
155
155
-
waitpid($pid, 0) or die;
156
156
-
if ($? != 0) {
157
157
-
print STDERR "failed to fetch $url: $?\n";
158
158
-
next;
156
156
+
# Substitute the output.
157
157
+
if (!isValidPath($storePath)) {
158
158
+
system("nix-store", "-r", $storePath);
159
159
}
160
160
-
<$fh>; my $storePath = <$fh>; chomp $storePath;
160
160
+
161
161
+
# Otherwise download the file using nix-prefetch-url.
162
162
+
if (!isValidPath($storePath)) {
163
163
+
$ENV{QUIET} = 1;
164
164
+
$ENV{PRINT_PATH} = 1;
165
165
+
my $fh;
166
166
+
my $pid = open($fh, "-|", "nix-prefetch-url", "--type", $algo, $url, $hash) or die;
167
167
+
waitpid($pid, 0) or die;
168
168
+
if ($? != 0) {
169
169
+
print STDERR "failed to fetch $url: $?\n";
170
170
+
next;
171
171
+
}
172
172
+
<$fh>; my $storePath2 = <$fh>; chomp $storePath2;
173
173
+
if ($storePath ne $storePath2) {
174
174
+
warn "strange: $storePath != $storePath2\n";
175
175
+
next;
176
176
+
}
177
177
+
}
161
178
162
179
uploadFile($storePath, $url);
163
180
$mirrored++;
+1
-1
maintainers/scripts/find-tarballs.nix
···
14
14
operator = const [ ];
15
15
});
16
16
17
17
-
urls = map (drv: { url = head (drv.urls or [ drv.url ]); hash = drv.outputHash; type = drv.outputHashAlgo; }) fetchurlDependencies;
17
17
+
urls = map (drv: { url = head (drv.urls or [ drv.url ]); hash = drv.outputHash; type = drv.outputHashAlgo; name = drv.name; }) fetchurlDependencies;
18
18
19
19
fetchurlDependencies =
20
20
filter