fix(flake): switch to useFetchCargoVendor for crates.io UA compatibility#22
Merged
Conversation
crates.io added a User-Agent blocklist in late April 2026 that rejects requests without an identifying UA. nixpkgs has two crate-fetching paths: - fetchCargoVendor — patched in NixOS/nixpkgs#512735 (merged 2026-04-26) to send 'User-Agent: nixpkgs fetchCargoVendor/2' and fetch from static.crates.io - importCargoLock — used by cargoLock.lockFile = ...; has its own inline fetchCrate calling fetchurl; NOT yet patched upstream; receives 403 on every crate download Switching to useFetchCargoVendor + cargoHash routes through the patched path. Cargo.lock stays as the source of truth; only the flake.nix attribute changes.
86edd29 to
5be838f
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.
Summary
CI broke because crates.io added a User-Agent blocklist in late April 2026 and tightened it further in late May. nixpkgs has two crate-fetching paths; only one was patched upstream.
Root cause
fetchCargoVendor(Python-based)User-Agent: nixpkgs fetchCargoVendor/2 (https://github.com/NixOS/nixpkgs)and fetches fromstatic.crates.ioimportCargoLock(used bycargoLock.lockFile = ...)fetchCratecallingfetchurlwhich still hits the API endpoint without a UA → HTTP 403Our flake used
cargoLock.lockFile = self + "/Cargo.lock"— the broken path. Everynix buildfailed with:Fix
Switch the build path:
Cargo.lockstays in the repo as the source of truth;fetchCargoVendorreads it via the vendor step.Verified locally
nix build .#default— succeedsnix develop --command validate-wrap just validate— passes (the exact command CI runs)Follow-up
This unblocks every PR in the repo. PR #20 (spec) and PR #21 (ladder) need to rebase onto this once merged; they'll then pass CI cleanly. Worth filing an upstream nixpkgs issue against
importCargoLocksince no fix is in flight there yet — separate from this PR.