2020-04-24 23:36:52 +00:00
|
|
|
let mirrors = import ./mirrors.nix; in
|
|
|
|
|
|
|
|
{ system }:
|
|
|
|
|
|
|
|
{ url ? builtins.head urls
|
|
|
|
, urls ? []
|
2022-09-09 14:08:57 +00:00
|
|
|
, sha256 ? ""
|
|
|
|
, hash ? ""
|
2020-04-24 23:36:52 +00:00
|
|
|
, name ? baseNameOf (toString url)
|
|
|
|
}:
|
|
|
|
|
2022-09-09 14:08:57 +00:00
|
|
|
# assert exactly one hash is set
|
|
|
|
assert hash != "" || sha256 != "";
|
|
|
|
assert hash != "" -> sha256 == "";
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
import <nix/fetchurl.nix> {
|
2022-09-09 14:08:57 +00:00
|
|
|
inherit system hash sha256 name;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|