Skip to content

Commit 02f21bf

Browse files
committed
fix(flake): switch to useFetchCargoVendor for crates.io UA compatibility
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.
1 parent c71451a commit 02f21bf

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

flake.nix

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,17 @@
3939
version = "0.1.0";
4040

4141
src = self;
42-
cargoLock.lockFile = self + "/Cargo.lock";
42+
43+
# crates.io began rejecting requests with no/generic User-Agent
44+
# in late May 2026 (HTTP 403). nixpkgs has two crate-fetching
45+
# paths; only `fetchCargoVendor` was patched upstream to send
46+
# an identifying UA and use static.crates.io
47+
# (NixOS/nixpkgs#512735). `cargoLock.lockFile` routes through
48+
# the older `importCargoLock` inline `fetchCrate` which is
49+
# still broken at HEAD. Use `cargoHash` + `useFetchCargoVendor`
50+
# to take the fixed path.
51+
useFetchCargoVendor = true;
52+
cargoHash = "sha256-diO7j+Dtzh8PhKMxzTk7pQ+VM7rCeGk29ba1upPyRJg=";
4353

4454
doCheck = false;
4555

@@ -57,7 +67,13 @@
5767

5868
packages = with pkgs; [
5969
toolchain
60-
fenix.packages.${system}.rust-analyzer
70+
# Use nixpkgs's pre-built rust-analyzer rather than fenix's
71+
# nightly. Fenix builds rust-analyzer from source, which
72+
# routes through the broken `importCargoLock` crate fetcher
73+
# and is currently blocked by crates.io's User-Agent policy
74+
# (see the cargoHash comment above). nixpkgs ships a binary
75+
# from cache.nixos.org — no crate fetching at build time.
76+
rust-analyzer
6177
jujutsu
6278
just
6379
alejandra

0 commit comments

Comments
 (0)