From 2f89220bdcbf8118db82753672684d8e27d4fc4c Mon Sep 17 00:00:00 2001 From: Marien Zwart Date: Sat, 25 May 2024 13:18:29 +1000 Subject: [PATCH] Try to work around Git caching issue in newer Nix After upgrading my local Nix from 2.18 to 2.22, evaluating Unstraightened became very slow. I think this is a bug in Nix (https://github.com/NixOS/nix/issues/10773), and it may explain the slowness I've been seeing in CI. Attempt to work around this by unconditionally passing `ref` to `fetchGit`. This seems like it should not do anything, since we also pass a `rev` and set `allRefs = true`, but it does work around the caching issue (mostly... it looks like submodules still hit it). Tested locally in both Nix 2.18 and Nix 2.22. I did see some odd warnings with 2.18 (`warning: refname 'e4031935803c66eca2f076dce72b0a6a770d026c' is ambiguous`), but only for one refname and they did not recur. Ignore that for now. --- default.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/default.nix b/default.nix index 634a387..e6039e9 100644 --- a/default.nix +++ b/default.nix @@ -244,7 +244,10 @@ let # TODO: pull ref from derivation.src when not pulling it from p.recipe? # Note Doom does have packages with pin + branch (or nonrecursive) set, # expecting to inherit the rest of the recipe from Straight. - } // optionalAttrs (p ? recipe.branch) { ref = p.recipe.branch; } + + # Always specify a ref to work around https://github.com/NixOS/nix/issues/10773 + ref = p.recipe.branch or "HEAD"; + } // optionalAttrs (p ? recipe.depth) { shallow = p.recipe.depth == 1; } ); # Run locally to avoid a network roundtrip.