Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at netboot-syslinux-multiplatform 25 lines 624 B view raw
1let mirrors = import ./mirrors.nix; in 2 3{ system }: 4 5{ url ? builtins.head urls 6, urls ? [] 7, sha256 ? "" 8, hash ? "" 9, name ? baseNameOf (toString url) 10}: 11 12# assert exactly one hash is set 13assert hash != "" || sha256 != ""; 14assert hash != "" -> sha256 == ""; 15 16import <nix/fetchurl.nix> { 17 inherit system hash sha256 name; 18 19 url = 20 # Handle mirror:// URIs. Since <nix/fetchurl.nix> currently 21 # supports only one URI, use the first listed mirror. 22 let m = builtins.match "mirror://([a-z]+)/(.*)" url; in 23 if m == null then url 24 else builtins.head (mirrors.${builtins.elemAt m 0}) + (builtins.elemAt m 1); 25}