2024-06-30 08:16:52 +00:00
|
|
|
let
|
|
|
|
mirrors = import ./mirrors.nix;
|
|
|
|
in
|
2024-05-02 00:46:19 +00:00
|
|
|
|
|
|
|
{ system }:
|
|
|
|
|
2024-06-30 08:16:52 +00:00
|
|
|
{
|
|
|
|
url ? builtins.head urls,
|
|
|
|
urls ? [ ],
|
|
|
|
sha256 ? "",
|
|
|
|
hash ? "",
|
|
|
|
name ? baseNameOf (toString url),
|
2024-05-02 00:46:19 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
# assert exactly one hash is set
|
|
|
|
assert hash != "" || sha256 != "";
|
|
|
|
assert hash != "" -> sha256 == "";
|
|
|
|
|
|
|
|
import <nix/fetchurl.nix> {
|
2024-06-30 08:16:52 +00:00
|
|
|
inherit
|
|
|
|
system
|
|
|
|
hash
|
|
|
|
sha256
|
|
|
|
name
|
|
|
|
;
|
2024-05-02 00:46:19 +00:00
|
|
|
|
|
|
|
url =
|
|
|
|
# Handle mirror:// URIs. Since <nix/fetchurl.nix> currently
|
|
|
|
# supports only one URI, use the first listed mirror.
|
2024-06-30 08:16:52 +00:00
|
|
|
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);
|
2024-05-02 00:46:19 +00:00
|
|
|
}
|