Skip to content

libfetchers/git: fix caching head when using shallow clones#12642

Merged
Mic92 merged 1 commit intoNixOS:masterfrom
Mic92:shallow-clone
Mar 12, 2025
Merged

libfetchers/git: fix caching head when using shallow clones#12642
Mic92 merged 1 commit intoNixOS:masterfrom
Mic92:shallow-clone

Conversation

@Mic92
Copy link
Member

@Mic92 Mic92 commented Mar 12, 2025

the old code was using the wrong cache directory, which lead to a warning on every nix flake update

Motivation

Context


Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

@Mic92 Mic92 requested a review from edolstra as a code owner March 12, 2025 21:28
@github-actions github-actions bot added the fetching Networking with the outside (non-Nix) world, input locking label Mar 12, 2025
the old code was using the wrong cache directory, which lead to a
warning on every nix flake update

Update src/libfetchers/git.cc
@Mic92 Mic92 enabled auto-merge March 12, 2025 21:34
@Mic92 Mic92 merged commit f4fd570 into NixOS:master Mar 12, 2025
12 checks passed
ysndr added a commit to flox/flox that referenced this pull request Jul 17, 2025
Flox, or more specifically nix expression builds, currently use nix
fetchers to fetch shallow git clones of nixpkgs. The git fetcher in Nix
< 2.29, was not consistently using the same cache dir for operations on
shallow clones, i.e. when computing cache path was determined
inconsistently via `getCachePath(<url>, getShallowAttr(input))`, and
`getCachePath(<url>, false)`.

The most easily observable effect were "fatal" git messages and Nix
warnings, as documented in <#3346>.
Whether it has further effect on the nixpkgs used, is unclear but
possible.

The bug was fixed in Nix >= 2.29 via
<NixOS/nix#12642>. Since the nix version used
here is still 2.28.3, backport the patch until our nixpkgs ships with a
patched distribution of nix.

Our nixpkgs _do_ include Nix 2.29, but using a pinned Nix, 1. increases
the risk of introducing more behavioral changes than including a single
few line patch 2. risks us potentially falling behind if we forget to
switch back to "stable" nix
github-merge-queue bot pushed a commit to flox/flox that referenced this pull request Jul 18, 2025
Flox, or more specifically nix expression builds, currently use nix
fetchers to fetch shallow git clones of nixpkgs. The git fetcher in Nix
< 2.29, was not consistently using the same cache dir for operations on
shallow clones, i.e. when computing cache path was determined
inconsistently via `getCachePath(<url>, getShallowAttr(input))`, and
`getCachePath(<url>, false)`.

The most easily observable effect were "fatal" git messages and Nix
warnings, as documented in <#3346>.
Whether it has further effect on the nixpkgs used, is unclear but
possible.

The bug was fixed in Nix >= 2.29 via
<NixOS/nix#12642>. Since the nix version used
here is still 2.28.3, backport the patch until our nixpkgs ships with a
patched distribution of nix.

Our nixpkgs _do_ include Nix 2.29, but using a pinned Nix,
1. increases the risk of introducing more behavioral changes than
including a single few line patch
2. risks us potentially falling behind if we forget to switch back to
"stable" nix
ysndr added a commit to flox/flox that referenced this pull request Nov 6, 2025
Drops the patches for 

* NixOS/nix#12580
* NixOS/nix#12642
* NixOS/nix#13340

All three have been merged upstream
in the current release of nix (v2.31.2).
ysndr added a commit to flox/flox that referenced this pull request Nov 6, 2025
Drops the patches for 

* NixOS/nix#12580
* NixOS/nix#12642
* NixOS/nix#13340

All three have been merged upstream
in the current release of nix (v2.31.2).
ysndr added a commit to flox/flox that referenced this pull request Nov 6, 2025
Drops the patches for 

* NixOS/nix#12580
* NixOS/nix#12642
* NixOS/nix#13340

All three have been merged upstream
in the current release of nix (v2.31.2).
ysndr added a commit to flox/flox that referenced this pull request Nov 7, 2025
Drops the patches for 

* NixOS/nix#12580
* NixOS/nix#12642
* NixOS/nix#13340

All three have been merged upstream
in the current release of nix (v2.31.2).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fetching Networking with the outside (non-Nix) world, input locking

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants