From fbe4906ac741e19e94ecc52c7dc690476013467d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=9C=BF=20corey?= Date: Wed, 27 May 2026 13:43:53 -0700 Subject: [PATCH] chore: work around crates.io 403 by injecting User-Agent into fetchcrate crates.io now returns HTTP 403 for requests from bare curl User-Agents under their API data access policy. nixpkgs fetchcrate sends no User-Agent, breaking any Rust package that fetches crates at build time (e.g. deploy-rs). This overlay wraps fetchcrate to inject a cargo-style User-Agent until nixpkgs fixes it upstream. Co-Authored-By: Claude Sonnet 4.6 --- overlays/default.nix | 3 +++ overlays/fetchcrate-ua.nix | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 overlays/fetchcrate-ua.nix diff --git a/overlays/default.nix b/overlays/default.nix index 45dcf619..e2478f7b 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -8,4 +8,7 @@ # Override opencode ahead of nixpkgs pin (import ./opencode.nix) + + # Inject User-Agent into fetchcrate so crates.io doesn't 403 + (import ./fetchcrate-ua.nix) ] diff --git a/overlays/fetchcrate-ua.nix b/overlays/fetchcrate-ua.nix new file mode 100644 index 00000000..32c2f587 --- /dev/null +++ b/overlays/fetchcrate-ua.nix @@ -0,0 +1,16 @@ +# Workaround for crates.io blocking bare curl User-Agents (HTTP 403). +# crates.io enforces a data access policy requiring descriptive User-Agents; +# nixpkgs fetchcrate sends none. Remove this overlay once upstream fixes it. +# https://crates.io/data-access +final: prev: { + fetchcrate = args: + prev.fetchcrate (args + // { + curlOptsList = + (args.curlOptsList or []) + ++ [ + "--user-agent" + "cargo/1.0 (nixpkgs; https://github.com/NixOS/nixpkgs)" + ]; + }); +}