blob: f1fc181ac3b6af1d5c4a0a3a9a626d4310145e6a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
let
inherit (builtins)
elemAt
head
isString
mapAttrs
match
;
# Handle mirror:// URIs. Since <nix/fetchurl.nix> currently
# supports only one URI, use the first listed mirror.
matchMirror = match "mirror://([a-z]+)/(.*)";
mirrors = mapAttrs (_: head) (import ./mirrors.nix);
in
{
rewriteURL,
system,
}:
let
handleUrl =
if rewriteURL == null then
url: url
else
url:
let
u = rewriteURL url;
in
if isString u then
u
else
throw "rewriteURL deleted the only URL passed to fetchurlBoot (was ${url})";
in
{
url ? head urls,
urls ? [ ],
sha256 ? "",
hash ? "",
name ? baseNameOf (toString url),
}:
# assert exactly one hash is set
assert hash != "" || sha256 != "";
assert hash != "" -> sha256 == "";
import <nix/fetchurl.nix> {
inherit
system
hash
sha256
name
;
url =
let
url_ = handleUrl url;
m = matchMirror url_;
in
if m == null then url_ else mirrors.${head m} + (elemAt m 1);
}
|