Allow fetching from multiple *private* git repositories mirrors #202
Reference in New Issue
Block a user
Delete Branch "robust-fetchGit"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Introduces the
builtin.catchAllfunction which can catch all errors produced by builtins, including those that builtins.fetchGit raise when the remote is down. This is then used to implementfetchGitMirrorwhich is equal to builtins.fetchGit, but accepts a list of urls instead of just one.Fixes: #200
14a67cda34to76aa169fe876aa169fe8tocc63e6f3f3cc63e6f3f3to9107cad6999107cad699to9b491e8d01WIP: Allow fetching from multiple *private* git repositories mirrorsto Allow fetching from multiple *private* git repositories mirrors@@ -98,2 +98,4 @@};# Load our custom lib functions with import, callPackage fails.lib' = import ./pkgs/lib.nix { lib = prev.lib; };We should also export the custom lib in the flake:
@@ -36,6 +35,7 @@ letmpich = callPackage ./pkgs/mpich/default.nix { mpich = prev.mpich; };nanos6 = callPackage ./pkgs/nanos6/default.nix { };nanos6Debug = final.nanos6.override { enableDebug = true; };nix = callPackage ./pkgs/nix/default.nix { nix = prev.nix; };Does the patch still apply to
nix_2_31(new stable in 25.11) ?The closest to
nix_2_31in 25.05 isnixVersions.gitat (2.31.0pre20250711_ab3cd76e)@@ -0,0 +2,4 @@let# If not supported, fall back to tryEval, which will fail in the first case.safeCatchAll = if (builtins ? catchAll)nit: no need for parentheses
@@ -0,0 +4,4 @@# If not supported, fall back to tryEval, which will fail in the first case.safeCatchAll = if (builtins ? catchAll)then builtins.catchAllelse e: (builtins.tryEval e) // { msg = ""; };I would add a warning here, something like:
catchAllwas not available on current nix, usingtryEvalas a fallback.Package consumers may be confused by it, so I would use
builtins.traceVerboseinstead oflib.warnso it's only shown when doingnix --verbose@@ -0,0 +16,4 @@letr = safeFetch url;inif (r.success) then rThis is
lib.warnIf@@ -0,0 +19,4 @@if (r.success) then relse lib.warn "cannot fetch ${url}, trying nextmirror:${builtins.replaceStrings ["\n" ] ["\n> "] ("\n"+r.msg)}" r;fetchList = lib.map (url: complain url) urls;No need for the lambda (
map (url: complain url) --> map complain)View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.