Skip to content

rustPlatform.importCargoLock: download crates from static.crates.io - #524985

Merged
philiptaron merged 1 commit into
NixOS:masterfrom
philiptaron:rustPlatform-importCargoLock-static-crates-io
May 27, 2026
Merged

philiptaron merged 1 commit into
NixOS:masterfrom
philiptaron:rustPlatform-importCargoLock-static-crates-io

Conversation

@philiptaron

Copy link
Copy Markdown
Contributor

The crates.io API server's 1 req/sec rate limit currently surfaces as intermittent HTTP 403 errors when vendoring lockfiles. Switch to the CDN endpoint as recommended by upstream (https://github.com/rust-lang/crates.io#13482), mirroring the fix already applied to fetchCargoVendor in #512735.

fetchurl is content-addressed by sha256, so the URL change does not affect any downstream store paths.

Fixes #524979

I used Claude Code to help with this patch.

Things done

The crates.io API server's 1 req/sec rate limit currently surfaces as
intermittent HTTP 403 errors when vendoring lockfiles. Switch to the CDN
endpoint as recommended by upstream (rust-lang/crates.io#13482), mirroring
the fix already applied to fetchCargoVendor in NixOS#512735.

fetchurl is content-addressed by sha256, so the URL change does not affect
any downstream store paths.

Fixes NixOS#524979

@PerchunPak PerchunPak left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes build failures for me

@nixpkgs-ci
nixpkgs-ci Bot requested a review from winterqt May 27, 2026 19:55
@nixpkgs-ci nixpkgs-ci Bot added 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 12.approvals: 1 This PR was reviewed and approved by one person. 6.topic: rust General-purpose programming language emphasizing performance, type safety, and concurrency. labels May 27, 2026
@philiptaron
philiptaron added this pull request to the merge queue May 27, 2026
Merged via the queue into NixOS:master with commit c0a89c3 May 27, 2026
31 checks passed
@philiptaron
philiptaron deleted the rustPlatform-importCargoLock-static-crates-io branch May 27, 2026 20:03
@nixpkgs-ci

nixpkgs-ci Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor

Successfully created backport PR for release-25.11:

@nixpkgs-ci

nixpkgs-ci Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor

Successfully created backport PR for release-26.05:

@github-actions github-actions Bot added the 8.has: port to stable This PR already has a backport to the stable release. label May 27, 2026
@niklaskorz

Copy link
Copy Markdown
Member

I used Claude Code to help with this patch.

The nixpkgs automation/AI policy requires disclosure through the Assisted-by: commit trailer. This PR does not follow the policy, eventhough it is marked as checked.

I see how this can be missed because of how pressing the issue itself is, but it should still be noted for future contributions.

@philiptaron

philiptaron commented May 27, 2026 •

Copy link
Copy Markdown
Contributor Author

Ah, I read the policy as requiring disclosure, not a specific form of disclosure. In this case, it's me making the commits, Claude doing the investigation as to what the crates.io boundary are. I think I'm in bounds.

@ZakarY2HM6f

Copy link
Copy Markdown

I know this is very new, is this backported to nixos-unstable any time soon?

pull Bot pushed a commit to ryoppippi/nix-ai-tools that referenced this pull request May 31, 2026
The nixpkgs input was pinned to nixos-unstable-small as a stopgap
(numtide#5254) because crates.io started rejecting curl/python-requests
user-agents, breaking rustPlatform.importCargoLock for all bun-based
packages.

The upstream fix (NixOS/nixpkgs#524985, importCargoLock downloads from
static.crates.io) has now reached the nixpkgs-unstable channel:

  $ gh api repos/NixOS/nixpkgs/compare/e9a7635a...c0a89c379b -q .status
  behind

Switch back to the regular channel as planned.

Closes numtide#5256
pull Bot pushed a commit to accelerating-returns-mirror/jj that referenced this pull request Jun 1, 2026
Includes NixOS/nixpkgs#524985, which fixes the
rate limits that were regularly hit while fetching dependencies from
crates.io.
samestep added a commit to gradbench/gradbench that referenced this pull request Jun 1, 2026
Switch `flake.nix` to a single nixpkgs input pointing at
`github:NixOS/nixpkgs/nixpkgs-unstable`, which has the User-Agent patch
for `fetchCargoVendor` (NixOS/nixpkgs#524985) -- the missing piece that
made floretta's vendor fetch fail with crates.io's 403. Floretta now
builds (its Rust tests run + pass during the build).

Drop the previously-separate `nixpkgs-unstable` input and its
`pkgsUnstable` plumbing through the flake's outputs and
`nix/registry.nix`; it had been threaded everywhere as an arg but no
package actually used it.

Bump `python311` -> `python312` in `nix/python.nix`, `nix/lib.nix`, and
`nix/devshell.nix`. Current `nixpkgs-unstable` has `python3.11-pip-25.3`
unbuildable because sphinx 9.1.0 (its build dep) dropped Python 3.11
support; `python3.12-pip-25.3` is fine. `pyproject.toml` already accepts
`>=3.11` and `uv.lock` carries cp312 wheels for everything heavy (torch,
jax/jaxlib, tensorflow, etc.).

Verified locally: all 16 heavy tools and 12 evals build; runtime checks
for hello/manual, gmm/pytorch, hello/floretta, hello/jax all pass.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
lunagl added a commit to lunagl/jj that referenced this pull request Jun 4, 2026
Includes NixOS/nixpkgs#524985, which fixes the
rate limits that were regularly hit while fetching dependencies from
crates.io.
lunagl added a commit to lunagl/jj that referenced this pull request Jun 4, 2026
Includes NixOS/nixpkgs#524985, which fixes the
rate limits that were regularly hit while fetching dependencies from
crates.io.
lunagl added a commit to lunagl/jj that referenced this pull request Jun 4, 2026
Includes NixOS/nixpkgs#524985, which fixes the
rate limits that were regularly hit while fetching dependencies from
crates.io.
lunagl added a commit to lunagl/jj that referenced this pull request Jun 4, 2026
Includes NixOS/nixpkgs#524985, which fixes the
rate limits that were regularly hit while fetching dependencies from
crates.io.
poelzi added a commit to poelzi/nix-suiup that referenced this pull request Jun 6, 2026
kp-mariappan-ramasamy added a commit to expressvpn/lightway that referenced this pull request Jun 8, 2026
The locked nixpkgs-unstable revision now includes NixOS/nixpkgs#524985
(merged 2026-05-27), which switches importCargoLock to download crates
from https://static.crates.io/crates. The backport overlay's
replaceStrings no longer matches anything, so it is a no-op. Remove it.
pull Bot pushed a commit to mikeyhodl/motoko that referenced this pull request Jun 18, 2026
…io` (caffeinelabs#6188)

`crates.io` has changed its rate limiting policy, which leads to
download failures when running the `vendor-rust-std-deps` command.

Changing to static.crates.io fixes the problem. See [a similar fix in
nixpkgs](NixOS/nixpkgs#524985) for reference.
mitchell-fanger added a commit to ldos-project/asterinas that referenced this pull request Aug 29, 2026
This PR is to update nixpkgs to 26.05. Previously, nixpkgs was pinned to
an older version that resulted in 403 errors because crates.io no longer
allows direct downloads.
[This](NixOS/nixpkgs#524985) nixpkgs update
fixed the issue by pointing to static.crates.io instead. We need to
upgrade our nixpkgs reference to 26.05 to include this fix.

In addition, 26.05 upgrades the gcc compiler, which uses c23, causing
one of the regression tests to fail. I fixed this by replacing
ATOMIC_VAR_INIT(0) with 0, because ATOMIC_VAR_INIT is deprecated in c23?
I think? Let me know if there's a better fix for this.

---------

Co-authored-by: mfanger <[email protected]>
ulic-youthlic added a commit to ulic-youthlic/helix that referenced this pull request Aug 31, 2026
Newer nixpkgs fetches crate tarballs from static.crates.io instead of
the rate-limited crates.io API, avoiding intermittent HTTP 403s.

This flake uses rustPlatform.importCargoLock (cargoLock in default.nix),
fixed in NixOS/nixpkgs#524985 (NixOS/nixpkgs#524979). Upstream:
rust-lang/crates.io#13482.

Also replace deprecated stdenv.isLinux/isx86_64 with hostPlatform.
ulic-youthlic added a commit to ulic-youthlic/helix that referenced this pull request Aug 31, 2026
Newer nixpkgs fetches crate tarballs from static.crates.io instead of
the rate-limited crates.io API, avoiding intermittent HTTP 403s.

This flake uses rustPlatform.importCargoLock (cargoLock in default.nix),
fixed in NixOS/nixpkgs#524985 (NixOS/nixpkgs#524979). Upstream:
rust-lang/crates.io#13482.

Also replace deprecated stdenv.isLinux/isx86_64 with hostPlatform.
@ognis1205 ognis1205 mentioned this pull request Sep 6, 2026
10 of 15 tasks
friedenberg added a commit to amarbel-llc/just-us that referenced this pull request Sep 9, 2026
Implements the `tools` facet of FDR 0004 on the same stdio MCP server
FDR 0005 introduced. `run_recipe` reuses the --events-fd (RFC 0002)
output-capture path with an in-memory EventSink instead of a real fd,
so a recipe's child stdout/stderr never leaks onto the server's own
stdout — the JSON-RPC channel. Documented as FDR 0006, with FDR 0004
updated to point at it for the MCP-server facet.

Also bumps the nixpkgs flake input (2026-03-24 -> 2026-09-08) to pick
up NixOS/nixpkgs#524985, which routes importCargoLock's per-crate
fetches through static.crates.io instead of crates.io's API domain —
the latter's WAF blocks any User-Agent containing "curl" (even
otherwise-compliant ones; see rust-lang/crates.io#13783), which was
breaking this repo's nix-sandboxed builds entirely.

AGENTS.md updated for the new tools capability per the doc-drift
convention already used for FDR 0005.
a0x8o pushed a commit to a0x8o/ironstar that referenced this pull request Sep 18, 2026
Every Rust gate failed at dependency vendoring. `crates.io/api/v1/crates`
rejects the `curl/<ver> Nix/<ver>` user agent that nixpkgs' `fetchurl`
sends, returning 403 on each crate; the static CDN serves the same bytes
to any user agent. Measured directly: the api/v1 URL returns 403 on
repeated requests with the default user agent and 200 with a descriptive
one, while `static.crates.io` returns 200 with the default user agent.
Not rate limiting, an address block, or network instability.

`modules/rust.nix` is the only affected fetch path. Its `cargoVendorDeps`
uses `rustPlatform.importCargoLock`, whose crate URLs come from the
pinned nixpkgs default download URL. The crate2nix `Cargo.nix` already
uses `static.crates.io` and is untouched.

The pinned nixpkgs (`nixos-26.05pre990408`, 2026-05-01) predates the
upstream correction (nixpkgs c0a89c37, NixOS/nixpkgs#524985, merged
2026-05-27 and backported to release-26.05 and release-25.11). Rather
than carry a patch or overlay, pass the identical upstream value through
`extraRegistries`, which the pinned `importCargoLock` already accepts and
merges over its default. A nixpkgs bump past c0a89c37 makes the argument
a redundant no-op and retires it.

The crate derivations are fixed-output, so store contents are unchanged:
the pre- and post-change derivations for `zenoh-util` declare the same
output path, `gjqb1kgiaw3jy1ybqf5xy8cxwfx0pvmd-crate-zenoh-util-1.7.2.tar.gz`.

Verified by forcing a network fetch with substituters disabled on the
exact crate that failed in nixbot build 5. The pre-change derivation
reproduces that failure verbatim (403, four retries, "cannot download
crate-zenoh-util-1.7.2.tar.gz from any mirror"); the post-change
derivation downloads 27101 bytes and succeeds.

Selection covers the change because the diff alters only crate download
URLs: the A/B fetch falsifies it directly, and the x86_64-linux
`cargo-vendor-dir` build exercises every crate URL on the platform that
failed. Compilation behaviour is unaffected by a URL, so the wider Rust
suite would add no discriminating signal.
hakula139 added a commit to hakulab/nixos-config that referenced this pull request Nov 9, 2026
The nixos-25.11 channel is frozen at the prior pin without NixOS/nixpkgs#524985,
so importCargoLock still pulls crates from the rate-limited crates.io API and
intermittently 403s, breaking the wsl and wsl-non-nixos builds. Advance the lock
to the release-25.11 rev that routes crate downloads to the static.crates.io CDN.

The input still tracks nixos-25.11, so `nix flake update nixpkgs` drops this pin
once the channel ships the backport.
hakula139 added a commit to hakulab/nixos-config that referenced this pull request Nov 14, 2026
The nixos-25.11 channel is frozen at the prior pin without NixOS/nixpkgs#524985,
so importCargoLock still pulls crates from the rate-limited crates.io API and
intermittently 403s, breaking the wsl and wsl-non-nixos builds. Advance the lock
to the release-25.11 rev that routes crate downloads to the static.crates.io CDN.

The input still tracks nixos-25.11, so `nix flake update nixpkgs` drops this pin
once the channel ships the backport.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: rust General-purpose programming language emphasizing performance, type safety, and concurrency. 8.has: port to stable This PR already has a backport to the stable release. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 12.approvals: 1 This PR was reviewed and approved by one person. backport release-26.05 Backport PR automatically

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rustPlatform.importCargoLock errors out with HTTP 403 error

4 participants