Skip to content

fix(flake): switch to useFetchCargoVendor for crates.io UA compatibility#22

Merged
ericbmerritt merged 1 commit into
mainfrom
fix/flake-fetchcargovendor
May 28, 2026
Merged

fix(flake): switch to useFetchCargoVendor for crates.io UA compatibility#22
ericbmerritt merged 1 commit into
mainfrom
fix/flake-fetchcargovendor

Conversation

@ericbmerritt

Copy link
Copy Markdown
Owner

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

Path Status
fetchCargoVendor (Python-based) Patched in NixOS/nixpkgs#512735 (merged 2026-04-26): sends User-Agent: nixpkgs fetchCargoVendor/2 (https://github.com/NixOS/nixpkgs) and fetches from static.crates.io
importCargoLock (used by cargoLock.lockFile = ...) Not patched. Has its own inline fetchCrate calling fetchurl which still hits the API endpoint without a UA → HTTP 403

Our flake used cargoLock.lockFile = self + "/Cargo.lock" — the broken path. Every nix build failed with:

trying https://crates.io/api/v1/crates/boxcar/0.2.14/download
curl: (22) The requested URL returned error: 403

Fix

Switch the build path:

- cargoLock.lockFile = self + "/Cargo.lock";
+ useFetchCargoVendor = true;
+ cargoHash = "sha256-diO7j+Dtzh8PhKMxzTk7pQ+VM7rCeGk29ba1upPyRJg=";

Cargo.lock stays in the repo as the source of truth; fetchCargoVendor reads it via the vendor step.

Verified locally

  • nix build .#default — succeeds
  • nix 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 importCargoLock since no fix is in flight there yet — separate from this PR.

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.
@ericbmerritt ericbmerritt force-pushed the fix/flake-fetchcargovendor branch from 86edd29 to 5be838f Compare May 28, 2026 17:14
@ericbmerritt ericbmerritt merged commit 02f21bf into main May 28, 2026
4 checks passed
@ericbmerritt ericbmerritt deleted the fix/flake-fetchcargovendor branch May 28, 2026 17:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant