Repository navigation
rustPlatform.importCargoLock: download crates from static.crates.io - #524985
philiptaron merged 1 commit into
Conversation
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
left a comment
There was a problem hiding this comment.
Fixes build failures for me
|
Successfully created backport PR for |
|
Successfully created backport PR for |
The nixpkgs automation/AI policy requires disclosure through the I see how this can be missed because of how pressing the issue itself is, but it should still be noted for future contributions. |
|
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. |
|
I know this is very new, is this backported to nixos-unstable any time soon? |
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
Includes NixOS/nixpkgs#524985, which fixes the rate limits that were regularly hit while fetching dependencies from crates.io.
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]>
Includes NixOS/nixpkgs#524985, which fixes the rate limits that were regularly hit while fetching dependencies from crates.io.
Includes NixOS/nixpkgs#524985, which fixes the rate limits that were regularly hit while fetching dependencies from crates.io.
Includes NixOS/nixpkgs#524985, which fixes the rate limits that were regularly hit while fetching dependencies from crates.io.
Includes NixOS/nixpkgs#524985, which fixes the rate limits that were regularly hit while fetching dependencies from crates.io.
…ixOS/nixpkgs#524985) Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
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.
…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.
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]>
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.
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.
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.
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.
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.
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.
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
fetchCargoVendorin #512735.fetchurlis 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
passthru.tests.nixpkgs-reviewon this PR. See nixpkgs-review usage../result/bin/.