Skip to content

fix(scripts): gate nixpkgs-unstable updates on Hydra-cached revision - #4558

Merged
dezren39 merged 1 commit into
mainfrom
fix/gate-nixpkgs-unstable-on-hydra
Nov 2, 2026
Merged

dezren39 merged 1 commit into
mainfrom
fix/gate-nixpkgs-unstable-on-hydra

Conversation

@dezren39

@dezren39 dezren39 commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Fixes #4553

What

scripts/update-nixpkgs-inputs.py (and its byte-identical pkgs/id/scripts/ copy) no longer advances the nixos-unstable inputs to branch HEAD. Inputs whose original.ref is nixos-unstable — currently nixpkgs-unstable and nixpkgs-25 — are gated on the binary cache: they pin to the newest revision Hydra has fully built for the channel.

Why

Branch HEAD runs days ahead of cache.nixos.org. The 2026-10-30 update pinned 31ecbaca before Hydra had built it and the amd toplevel became a multi-day source build (see #2715 / PR #4519).

Mechanism

  1. Resolve the gate before any input is touched: GET https://hydra.nixos.org/job/nixos/unstable/tested/latest-finished (Accept: application/json, redirects followed) → jobsetevals[0] → GET /eval/<id> → jobsetevalinputs.nixpkgs.revision (validated as a full 40-hex rev; a non-zero buildstatus or any unexpected payload shape aborts).
  2. Fetch that revision once with nix flake metadata github:NixOS/nixpkgs/<rev> --json and take its locked attrs (rev, narHash, lastModified — from a real nix fetch, never copied from another rev).
  3. Rewrite only each gated node's locked entry in flake.lock (nix's own JSON formatting, verified byte-stable); original — including ref: nixos-unstable — is untouched, so discovery in this script and nix/nixpkgs-inputs.nix keeps matching.
  4. Already at the Hydra revision → reported skipped, file untouched. Master / no-ref inputs keep the existing branch-HEAD nix flake update behaviour.
  5. Fail closed: Hydra unreachable or payload shape unexpected → exit non-zero with a clear message, flake.lock untouched. UPDATE_NIXPKGS_HYDRA_URL overrides the Hydra base URL (used by tests).

One environment fix along the way: the script runs under uv run --script, whose standalone Python can load 0 CA certs (every HTTPS request fails CERTIFICATE_VERIFY_FAILED). https_context() falls back to the standard system bundle locations when the default context is empty — verification stays on (pinned by a contract test).

Tests

  • Contract tests (scripts/tests/test_update_nixpkgs_inputs.py, the file CI runs): all 14 pass, including new gate coverage for both copies — Hydra parse/fail-closed shapes against a local stub server, end-to-end pin (only the gated locked entry changes, original preserved, exactly one nix call — never flake update), byte-identical no-op rerun, and Hydra-failure ⇒ non-zero exit with the lock untouched.
  • Live run in this worktree against the real flake.lock (old pins 6510408d/e7439b6b): both inputs pinned to the live Hydra revision 0bb2eedc20e4739f29e8045034f2828ad7054f8f (eval 1830926); written locked entries verified byte-equal to an independent nix flake metadata fetch; nixpkgs-master/nixpkgs-stable nodes identical; nix flake metadata on the repo resolves both inputs to the Hydra rev. Rerun = clean no-op (lock sha unchanged). With UPDATE_NIXPKGS_HYDRA_URL=http://127.0.0.1:9: exit 1, lock untouched. (The test pins were reverted — this PR changes the script, not main's pins.)
  • nix run .#format-check on the three changed files: clean.

Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

update-nixpkgs-inputs.py advanced every input to branch HEAD. For the
nixos-unstable ref set that pins revisions Hydra has not built yet and
cache.nixos.org does not serve — the 2026-10-30 update pinned 31ecbaca
before it was cached and turned the amd toplevel into a multi-day
source build (#2715, PR #4519).

Inputs whose original.ref is nixos-unstable (nixpkgs-unstable,
nixpkgs-25) now pin to the newest revision Hydra has fully built for
the channel: GET /job/nixos/unstable/tested/latest-finished ->
jobsetevals[0] -> GET /eval/<id> -> jobsetevalinputs.nixpkgs.revision.
The pin rewrites only the node's locked entry, with rev/narHash/
lastModified from a real 'nix flake metadata' fetch of that revision;
original (incl. ref) is untouched, so discovery keeps matching. The
gate resolves before any input is touched and fails closed: a Hydra
lookup failure or unexpected payload shape exits non-zero with
flake.lock untouched. Master/no-ref inputs keep branch-HEAD behaviour.

The pkgs/id copy gets the identical change (the two copies are pinned
byte-identical by contract test). Contract tests cover the Hydra
parsing/fail-closed shapes, the end-to-end pin against a local Hydra
stub (pin, no-op rerun, failure leaves the lock untouched), and that
the HTTPS context keeps verification on — uv's standalone Python can
load 0 CA certs, so https_context() falls back to the system bundle
locations rather than failing or disabling verification.

Fixes #4553
@dezren39
dezren39 requested a review from a team as a code owner November 2, 2026 20:06
@coderabbitai

coderabbitai Bot commented Nov 2, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 13 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f5ed23cc-70ac-47b6-ad8c-e4fa5946f183
Commits

Reviewing files that changed from the base of the PR and between e220845 and 2d63376.

Files selected for processing: 3
  • pkgs/id/scripts/update-nixpkgs-inputs.py
  • scripts/tests/test_update_nixpkgs_inputs.py
  • scripts/update-nixpkgs-inputs.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-02T20:08:39.330124Z 2d63376 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@dezren39
dezren39 merged commit 12da950 into main Nov 2, 2026
2 checks passed
@dezren39
dezren39 deleted the fix/gate-nixpkgs-unstable-on-hydra branch November 2, 2026 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(scripts): gate nixpkgs-unstable input updates on the Hydra channel (cached) revision

1 participant