From 1d61287aff5b9665458e0adedc7fdc19858e2276 Mon Sep 17 00:00:00 2001 From: Marien Zwart Date: Tue, 2 Jul 2024 21:41:10 +1000 Subject: [PATCH 1/5] Avoid shallow clone of notmuch Shallow clones are the default in Nix 2.23, but the Git server for notmuch does not seem to allow shallow clones of specific revisions. Disable them, which should make no difference for Nix < 2.23. This is mostly to (hopefully) unblock CI. If this fixes it, I should investigate if it is possible for Nix to fall back to a full clone in this scenario. --- default.nix | 5 +++-- fetch-overrides.nix | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/default.nix b/default.nix index c6be253..c4a45b5 100644 --- a/default.nix +++ b/default.nix @@ -59,7 +59,7 @@ }: let inherit (lib) optionalAttrs optionalString; - inherit (import ./fetch-overrides.nix) extraPins extraUrls; + inherit (import ./fetch-overrides.nix) extraPins extraUrls forceDeepClone; # Step 1: determine which Emacs packages to pull in. # @@ -260,7 +260,8 @@ let } // optionalAttrs (p ? recipe.branch) { ref = p.recipe.branch; } - // optionalAttrs (p ? recipe.depth) { shallow = p.recipe.depth == 1; }; + // optionalAttrs (p ? recipe.depth) { shallow = p.recipe.depth == 1; } + // optionalAttrs (forceDeepClone.${url} or false) { shallow = false; }; src = if experimentalFetchTree then builtins.fetchTree ( diff --git a/fetch-overrides.nix b/fetch-overrides.nix index 6da2a83..e7f978e 100644 --- a/fetch-overrides.nix +++ b/fetch-overrides.nix @@ -54,4 +54,9 @@ # CI should fail again the next time Doom updates magit, so this won't go stale. git-commit = "ea0f07e54967197ac0b072a69ba314314a4080c1"; }; + + # Repositories for which to force `shallow = false`. + forceDeepClone = { + "https://git.notmuchmail.org/git/notmuch" = true; + }; } From 37da9ce04592299d0e40df6ff0bceacd60873034 Mon Sep 17 00:00:00 2001 From: Marien Zwart Date: Tue, 2 Jul 2024 21:59:49 +1000 Subject: [PATCH 2/5] Extend/generalize shallow clone avoidance Savannah seems to have the same problem. CI fails for emms. Extend to all of savannah as we'll presumably hit this for several other packages next... --- default.nix | 6 ++++-- fetch-overrides.nix | 9 +++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/default.nix b/default.nix index c4a45b5..781f739 100644 --- a/default.nix +++ b/default.nix @@ -59,7 +59,7 @@ }: let inherit (lib) optionalAttrs optionalString; - inherit (import ./fetch-overrides.nix) extraPins extraUrls forceDeepClone; + inherit (import ./fetch-overrides.nix) extraPins extraUrls forceDeepCloneDomains; # Step 1: determine which Emacs packages to pull in. # @@ -261,7 +261,9 @@ let } // optionalAttrs (p ? recipe.branch) { ref = p.recipe.branch; } // optionalAttrs (p ? recipe.depth) { shallow = p.recipe.depth == 1; } - // optionalAttrs (forceDeepClone.${url} or false) { shallow = false; }; + // optionalAttrs (lib.any (d: lib.hasPrefix d url) forceDeepCloneDomains) { + shallow = false; + }; src = if experimentalFetchTree then builtins.fetchTree ( diff --git a/fetch-overrides.nix b/fetch-overrides.nix index e7f978e..fd96189 100644 --- a/fetch-overrides.nix +++ b/fetch-overrides.nix @@ -55,8 +55,9 @@ git-commit = "ea0f07e54967197ac0b072a69ba314314a4080c1"; }; - # Repositories for which to force `shallow = false`. - forceDeepClone = { - "https://git.notmuchmail.org/git/notmuch" = true; - }; + # Domains for which to force `shallow = false`. + forceDeepCloneDomains = [ + "https://git.notmuchmail.org/" + "https://git.savannah.gnu.org/" + ]; } From 969837731b9331be48ea54d79c1397421a5baa77 Mon Sep 17 00:00:00 2001 From: Marien Zwart Date: Tue, 2 Jul 2024 22:15:19 +1000 Subject: [PATCH 3/5] Use sourcehut fetcher It looks like sourcehut does not allow shallow clones of arbitrary revs either. Use Nix's experimental archive fetcher for more optimal fetches. --- default.nix | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/default.nix b/default.nix index 781f739..d199087 100644 --- a/default.nix +++ b/default.nix @@ -277,6 +277,16 @@ let type = "github"; inherit owner repo; rev = pin; + } else if lib.hasPrefix "https://git.sr.ht/" url + then let + tail = lib.removePrefix "https://git.sr.ht/" url; + split = lib.splitString "/" tail; + owner = lib.head split; + repo = lib.elemAt split 1; + in { + type = "sourcehut"; + inherit owner repo; + rev = pin; } else ({ type = "git"; } // fetchGitArgs)) From 257a75855cc948362304c6966fc0495936837ff7 Mon Sep 17 00:00:00 2001 From: Marien Zwart Date: Tue, 2 Jul 2024 22:17:20 +1000 Subject: [PATCH 4/5] Disable shallow fetches for sourcehut They do not seem to work. --- fetch-overrides.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/fetch-overrides.nix b/fetch-overrides.nix index fd96189..f2cd8ee 100644 --- a/fetch-overrides.nix +++ b/fetch-overrides.nix @@ -59,5 +59,6 @@ forceDeepCloneDomains = [ "https://git.notmuchmail.org/" "https://git.savannah.gnu.org/" + "https://git.sr.ht/" ]; } From dc0541b3a8b429aab78a9e2610f14d7cead94043 Mon Sep 17 00:00:00 2001 From: Marien Zwart Date: Tue, 2 Jul 2024 22:25:59 +1000 Subject: [PATCH 5/5] Disable shallow clones from codeberg They do not seem to work either. --- fetch-overrides.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/fetch-overrides.nix b/fetch-overrides.nix index f2cd8ee..eb989ef 100644 --- a/fetch-overrides.nix +++ b/fetch-overrides.nix @@ -60,5 +60,6 @@ "https://git.notmuchmail.org/" "https://git.savannah.gnu.org/" "https://git.sr.ht/" + "https://codeberg.org/" ]; }