Repository navigation
pins: fall back to fetchTarball/fetchGit on Nix 2.3 - #19
Merged
Merged
Conversation
This was referenced Nov 10, 2026
`builtins.fetchTree` does not exist in Nix 2.3, so importing pins.nix failed there. Add fetch-locked.nix, a small helper shared verbatim across corepkgs, ekapkgs, python-packages and vim-plugins: it resolves a root input of flake.lock (following `follows`) and fetches it with `fetchTree` when available, otherwise with `fetchTarball` (github) or `fetchGit` (git). Both paths yield the same store path, so drvPaths are unchanged, and flake.lock remains the single source of truth.
jonringer
force-pushed
the
jonringer/nix-2-3-pins
branch
from
November 13, 2026 22:15
898a2e8 to
614e6ea
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The roadmap says every repository should be Nix 2.3 compatible, but
pins.nixcallsbuiltins.fetchTree, which Nix 2.3 doesn't have. Importingdefault.nixwith Nix 2.3 therefore fails immediately withattribute 'fetchTree' missing.Approach
This adds
fetch-locked.nix, a ~45-line helper. The same file is vendored byte-for-byte in all four repos (corepkgs, ekapkgs, python-packages, vim-plugins), and each repo'spins.nixbecomes onefetchLocked "<input>"line per pin:flake.lock, so that file stays the single source of truth andnix flake update/nix flake lockkeep driving the non-flake pins. It looks up a root input by name and followsfollowspaths such asnix-lib = ["corepkgs" "nix-lib"], so it doesn't depend on the lock's internal node names (foo_2, ...).builtins.fetchTree locked, the same as before (this is also whatnix flakedoes).githubinputs go throughbuiltins.fetchTarball { url = "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"; sha256 = locked.narHash; }.gitinputs go throughbuiltins.fetchGit { url; rev; ref?; }. Nix 2.3 rejectsallRefsandsubmodules("unsupported argument"), so they aren't passed, and asubmodules = trueinput throws a clear error. Note that 2.3'sfetchGitdoes not check narHash.{ outPath; rev; narHash; }, soimport pins.x,pins.x + "/file"and.outPathkeep working.sourceplus the locked narHash).All
flake.lockentries in the four repos aregithub. Thegitpath was tested against a synthetic lock entry. Arefis needed on 2.3 for a rev that isn't on the default branch, and 2.3 acceptsref = "refs/heads/<branch>".Verification
All of this ran on Nix 2.34.8 unless noted otherwise.
drvPaths before vs after vs forced fallback. I evaluated
(import ./default.nix {}).<attr>.drvPathonorigin/master, on this branch, and on a copy of this branch whosepins.nixpassesfetchers = removeAttrs builtins [ "fetchTree" ]to force the Nix 2.3 code path. All three are identical:python3Packages.requests/nix/store/7p2fff2gns5k4ifjfrb2vs3an3rrf86f-python3.13-requests-2.34.2.drvpython3Packages.numpy/nix/store/81nx0i56smp6n1pmrvfhnrvkhx7q2fiq-python3.13-numpy-2.5.4.drvopenssl/nix/store/7dk1flqpq2qsl525qzxwk5bziqz25jj1-openssl-3.6.3.drvEach pin's
outPathis also identical between thefetchTreepath and the fallback path. The flake output can't be compared here because it fails to evaluate onorigin/mastertoo (see below).Real Nix 2.3.16 (
nixVersions.nix_2_3from nixos-23.05, run against the local daemon):builtins ? fetchTreeisfalse, andimport ./pins.nixnow evaluates. For every pin, the store path is the onefetchTreegives on 2.34 (e.g. nix-lib a52fa86 ->/nix/store/dj7zb40ak0l9f4510gggycs04wv4laii-source).fetchTarball. A corruptedsha256-...value is rejected withhash mismatch ... wanted: sha256:1a8fng...0000 got: sha256:1a8fng...kwjj2, so the hash is parsed and checked, not ignored.fetchGiton 2.3: the default-branch rev with noref, a non-default-branch rev withref, and the forced-fallback path on 2.34 all give the same store path asfetchTreeon 2.34.Caveat: the full package set does not evaluate on Nix 2.3 yet. This PR only fixes the pinning layer. With these changes, Nix 2.3 gets past
pins.nixand then fails on newer syntax elsewhere in corepkgs. The first failure is path interpolation (./${majorVersion}/...inpkgs/gcc/patches/default.nix), which needs Nix 2.4. Downstream repos also need theirflake.lockbumped to a corepkgs that includes the corepkgs PR before their transitive pins work on 2.3.Formatting.
nix fmthere buildsnixfmt-rsfrom the corepkgs bootstrap (there's no cache hit locally), which wasn't practical to finish. The changed files were instead checked withnixfmt-rs0.4.1 andnixfmt1.4.0, and both made no changes.CI.
ci/eval.shpasses: all 7238 packages evaluate.Pre-existing, unrelated issue.
nix eval .#legacyPackages.x86_64-linux.<attr>already fails onorigin/masterwithfunction 'anonymous lambda' called with unexpected argument 'system':default.nixtakes no...butflake.nixpassessystem. It's unchanged by this PR and not addressed here.Sibling PRs
All four PRs use the identical
fetch-locked.nix: