nixpkgs/pkgs/build-support/fetchurl/boot.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

26 lines
624 B
Nix
Raw Normal View History

let mirrors = import ./mirrors.nix; in
{ system }:
{ url ? builtins.head urls
, urls ? []
2022-08-23 12:06:54 +01:00
, sha256 ? ""
, hash ? ""
2017-08-04 07:22:04 +01:00
, name ? baseNameOf (toString url)
}:
2022-08-23 12:06:54 +01:00
# assert exactly one hash is set
assert hash != "" || sha256 != "";
assert hash != "" -> sha256 == "";
import <nix/fetchurl.nix> {
2022-08-23 12:06:54 +01:00
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);
}