fix(l2): override Nix daemon User-Agent so crates.io stops 403ing the TDX image build#6739
Conversation
…X image build crates.io now returns HTTP 403 to any request whose User-Agent contains the substring "curl/". Nix's fetchurl — used by rustPlatform.importCargoLock to vendor crates for the TDX quote-gen image — sends "curl/<ver> Nixpkgs/<ver>", so every crate download during `make image.raw` fails. This breaks the "L2 TDX build" job on main and on every PR. fetchurl appends $NIX_CURL_FLAGS to its curl invocation (the last --user-agent wins) and whitelists it in impureEnvVars, so it reaches the sandboxed crate fixed-output derivations. Set it on the nix-build command to override the User-Agent with one crates.io accepts. It is set inline rather than via `export` because GNU Make's $(shell ...) does not inherit exported variables, and as a single space-free token because fetchurl word-splits the value.
|
🤖 Kimi Code ReviewThe fix is correct and properly addresses the crates.io User-Agent blocking issue. A few observations: Line 12-16 (Makefile) Line 19 & 23 (Makefile) Minor suggestion: NIX_ENV = NIX_CURL_FLAGS="$(NIX_CURL_FLAGS) --user-agent ethrex-ci+https://github.com/lambdaclass/ethrex"However, given that this is a CI/build-specific Makefile and the primary use case is overriding the problematic default User-Agent, the current approach is acceptable. Verdict: The change is correct, well-documented, and addresses the infrastructure issue without introducing security or correctness risks. Automated review by Kimi (Moonshot AI) · kimi-k2.5 · custom prompt |
🤖 Claude Code ReviewPR #6739 Review — fix(l2): set Nix fetchurl User-Agent so crates.io stops 403ing the TDX image buildOverviewA targeted one-file fix for a CI-wide breakage: crates.io now returns HTTP 403 to any request whose Correctness
Potential Issues / Risks
Style / Comment LengthThe 7-line comment block is thorough, which aids future maintainers who may not know this Nix internals detail. Given that this is a non-obvious workaround for an external policy change, the verbosity is justified. No changes needed. SummaryThe fix is correct, minimal, well-explained, and covers all affected targets. The only non-trivial concern is the informality of the User-Agent string — not a blocker, but if crates.io ever enforces a stricter format, the string at line 13 of the Makefile is the single place to update. Verdict: LGTM with no blocking issues. Automated review by Claude (Anthropic) · sonnet · custom prompt |
🤖 Codex Code ReviewNo findings. The patch is narrowly scoped and looks correct in crates/l2/tee/quote-gen/Makefile. Prefixing the two existing Residual note: I did not execute the Nix build in this environment, so this review is static; the only practical thing to confirm outside review is that your pinned Nix tooling still propagates Automated review by OpenAI Codex · gpt-5.4 · custom prompt |
Greptile SummaryThis PR fixes a CI-blocking issue where crates.io began returning HTTP 403 to requests with a
Confidence Score: 5/5Safe to merge — single-file change that corrects an environment variable passed to nix-build, with no logic changes to the build outputs themselves. The change is minimal and self-contained: it adds one Make variable and prepends it to the two existing nix-build invocations. The user-agent value is space-free (avoiding word-split pitfalls in fetchurl), the inline assignment correctly sidesteps the GNU Make $(shell) inheritance limitation, and both targets that trigger crate downloads are covered. No files require special attention.
|
| Filename | Overview |
|---|---|
| crates/l2/tee/quote-gen/Makefile | Adds NIX_ENV variable with NIX_CURL_FLAGS override to bypass crates.io's 403 on curl User-Agent; applied to both image.raw and run targets. Logic is sound and well-commented. |
Reviews (1): Last reviewed commit: "fix(l2): set Nix fetchurl User-Agent so ..." | Re-trigger Greptile
There was a problem hiding this comment.
Pull request overview
This PR updates the TDX quote-gen image build entrypoint to work around crates.io returning HTTP 403 for requests whose User-Agent contains curl/, by overriding Nix fetchurl’s curl flags via NIX_CURL_FLAGS during nix-build invocations.
Changes:
- Add
NIX_ENVto injectNIX_CURL_FLAGSwith a crates.io-acceptedUser-Agent. - Apply that environment override to the
nix-buildcalls used bymake image.rawandmake run. - Document the rationale and how the environment variable reaches sandboxed fixed-output derivations.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # crates.io accepts. Set inline on the nix-build command rather than via `export` | ||
| # because GNU Make's $(shell ...) does not inherit exported variables. |
| # derivation sandbox via impureEnvVars, so we override the User-Agent with one | ||
| # crates.io accepts. Set inline on the nix-build command rather than via `export` | ||
| # because GNU Make's $(shell ...) does not inherit exported variables. | ||
| NIX_ENV = NIX_CURL_FLAGS="--user-agent ethrex-ci+https://github.com/lambdaclass/ethrex" |
…t the client
The previous Makefile NIX_CURL_FLAGS override was inert: install-nix-action runs
Nix in multi-user (daemon) mode, so the crate fixed-output derivations are built
by the nix-daemon, which does not inherit the caller's environment. The override
never reached the crate downloads and they kept 403ing.
crates.io returns HTTP 403 for any User-Agent containing the substring "curl/",
which is what Nix's fetchurl sends by default ("curl/<ver> Nixpkgs/<ver>").
Fix it at the daemon layer via Nix's `impure-env` setting (the documented
mechanism for passing env into fixed-output derivations in a multi-user
install — its canonical use is https_proxy for the daemon), set through
install-nix-action's extra_nix_config in both workflows that build the TDX
image. impure-env is honored because the runner is a trusted user. The
User-Agent uses the `--user-agent=<value>` form so it stays a single token
through impure-env's space-separated parsing and fetchurl's unquoted word-split,
and overrides fetchurl's default (curl honors the last --user-agent).
Reverts the earlier Makefile change, which only helped single-user/local Nix.
The impure-env override reached the daemon's crate fetches, but curl rejected the value: `curl: option --user-agent=ethrex-ci+...: is unknown`. curl does not accept the `--long=value` form — it requires a space — but impure-env splits on spaces, so the value cannot contain one. Use curl's glued short option `-A<value>`, a single space-free token curl parses correctly, which still overrides fetchurl's default User-Agent (last occurrence wins).
Motivation
The TDX image build (
make image.raw, in the L2 TDX build and L2 (without proving) workflows) is failing onmainand on every PR. crates.io now returns HTTP 403 to any request whoseUser-Agentcontains the substringcurl/. Nix'sfetchurl— used byrustPlatform.importCargoLockto vendor crates for the TDXquote-genimage — sendsUser-Agent: curl/<ver> Nixpkgs/<ver>, so every crate download 403s and the build fails:It's an external crates.io policy change, which is why it breaks
mainand all PRs at once.Description
install-nix-actionruns Nix in multi-user (daemon) mode, so the crate fixed-output derivations are built by thenix-daemon, which does not inherit the caller's environment. The fix therefore has to reach the daemon, via Nix'simpure-envsetting — the documented mechanism for passing environment into fixed-output derivations in a multi-user install (its canonical use ishttps_proxyfor the daemon). It is honored because the CI runner is a trusted user.fetchurlappends$NIX_CURL_FLAGSto itscurlinvocation (curl honors the last--user-agent), so we set it to acurl/-free User-Agent. The--user-agent=<value>form keeps it a single token throughimpure-env's space-separated parsing andfetchurl's unquoted word-split.Applied to both workflows that run
make image.raw. The earlier Makefile-levelNIX_CURL_FLAGSoverride is reverted — it was inert in daemon mode (only single-user/local Nix would have seen it).How to Test
Verified end-to-end via CI on this PR (the L2 TDX build check).