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