depot/third_party/nixpkgs/pkgs/build-support/fetchurl/boot.nix
Default email 8ac5e011d6 Project import generated by Copybara.
GitOrigin-RevId: 2c3273caa153ee8eb5786bc8141b85b859e7efd7
2020-04-24 19:36:52 -04:00

20 lines
498 B
Nix

let mirrors = import ./mirrors.nix; in
{ system }:
{ url ? builtins.head urls
, urls ? []
, sha256
, name ? baseNameOf (toString url)
}:
import <nix/fetchurl.nix> {
inherit system 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);
}