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.
This commit is contained in:
Marien Zwart 2024-05-25 13:18:29 +10:00
parent 6401eecb57
commit 2f89220bdc
No known key found for this signature in database

View file

@ -244,7 +244,10 @@ let
# TODO: pull ref from derivation.src when not pulling it from p.recipe? # TODO: pull ref from derivation.src when not pulling it from p.recipe?
# Note Doom does have packages with pin + branch (or nonrecursive) set, # Note Doom does have packages with pin + branch (or nonrecursive) set,
# expecting to inherit the rest of the recipe from Straight. # 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; } // optionalAttrs (p ? recipe.depth) { shallow = p.recipe.depth == 1; }
); );
# Run locally to avoid a network roundtrip. # Run locally to avoid a network roundtrip.