nix-prefetch-git: fetch the fetching tag for NIX_PREFETCH_GIT_CHECKOUT_HOOK

Co-authored-by: Adam Dinwoodie <adam@dinwoodie.org>
This commit is contained in:
Yueh-Shun Li
2025-12-17 01:14:55 +08:00
co-authored by Adam Dinwoodie
parent cbd24f4a8a
commit d4dd261ab5
2 changed files with 17 additions and 0 deletions
@@ -258,6 +258,13 @@ clone(){
clean_git fetch origin 'refs/tags/*:refs/tags/*' || echo "warning: failed to fetch some tags" >&2
fi
# Name "$ref" to make `git describe` work reproducibly in `NIX_PREFETCH_GIT_CHECKOUT_HOOK`.
# Name only when not leaving `.git` for compatibility purposes.
if [[ -n "$ref" ]] && [[ -z "$leaveDotGit" ]]; then
echo "refer to FETCH_HEAD as its original name $ref"
clean_git update-ref "$ref" FETCH_HEAD
fi
# Checkout linked sources.
if test -n "$fetchSubmodules"; then
init_submodules
+10
View File
@@ -34,6 +34,16 @@
hash = "sha256-7DszvbCNTjpzGRmpIVAWXk20P0/XTrWZ79KSOGLrUWY=";
};
describe-tag = testers.invalidateFetcherByDrvHash fetchgit {
name = "describe-tag-nix-source";
url = "https://github.com/NixOS/nix";
tag = "2.3.15";
hash = "sha256-y7l+46lVP2pzJwGON5qEV0EoxWofRoWAym5q9VXvpc8=";
postCheckout = ''
{ git -C "$out" describe || echo "git describe failed"; } | tee "$out"/describe-output.txt
'';
};
sparseCheckout = testers.invalidateFetcherByDrvHash fetchgit {
name = "sparse-checkout-nix-source";
url = "https://github.com/NixOS/nix";