31 lines
978 B
Nix
31 lines
978 B
Nix
{ lib }:
|
|
|
|
let
|
|
# If not supported, fall back to tryEval, which will fail in the first case.
|
|
safeCatchAll = if (builtins ? catchAll)
|
|
then builtins.catchAll
|
|
else e: (builtins.tryEval e) // { msg = ""; };
|
|
in lib.extend (_: lib: {
|
|
# Same as fetchGit but accepts a list of mirror urls
|
|
fetchGitMirror = { urls, ... } @ args:
|
|
let
|
|
cleanArgs = lib.removeAttrs args [ "urls" ];
|
|
fetchUrl = url: builtins.fetchGit (cleanArgs // { inherit url; });
|
|
safeFetch = url: safeCatchAll (fetchUrl url);
|
|
complain = url:
|
|
let
|
|
r = safeFetch url;
|
|
in
|
|
if (r.success) then r
|
|
else lib.warn "cannot fetch ${url}, trying next
|
|
mirror:${builtins.replaceStrings ["\n" ] ["\n> "] ("\n"+r.msg)}" r;
|
|
fetchList = lib.map (url: complain url) urls;
|
|
bad = throw "cannot fetch from any mirror";
|
|
good = lib.findFirst (e: e.success) bad fetchList;
|
|
in good.value;
|
|
|
|
maintainers = lib.maintainers // {
|
|
bsc = import ./maintainers.nix;
|
|
};
|
|
})
|