blob: 4aa76094a843e8cb236d152ee0363d629daf6866 (
plain) (
blame)
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
|
let
mirrors = import ./mirrors.nix;
in
{ system }:
{
url ? builtins.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 =
# Handle mirror:// URIs. Since <nix/fetchurl.nix> currently
# supports only one URI, use the first listed mirror.
let
m = builtins.match "mirror://([a-z]+)/(.*)" url;
in
if m == null then url else builtins.head (mirrors.${builtins.elemAt m 0}) + (builtins.elemAt m 1);
}
|