Skip to content

Carry the system libraries nixpkgs' codex does not declare - #30

Merged
jgus merged 3 commits into
mainfrom
agent/codex-sys-libs
Nov 10, 2026
Merged

jgus merged 3 commits into
mainfrom
agent/codex-sys-libs

Conversation

@jgus-bot

@jgus-bot jgus-bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Why

A consumer's nightly updater (jgus-org/nix, flake-update.service on d1, severity critical) is red because of this flake's package. nixpkgs' cargo hook now makes every Rust crate that accepts one probe for a system library instead of building its vendored copy, so a package that does not declare that library fails where it used to succeed. Upstream's fix for codex is NixOS/nixpkgs#584667; the symptom is:

thread 'main' (6358) panicked at /build/codex-0.167.0-vendor/source-registry-0/zstd-sys-2.0.16+zstd.1.5.7/build.rs:60:10:
Can't probe for zstd in pkg-config:
pkg-config exited with status code 1
> PKG_CONFIG_PATH=...openssl-3.5.9-dev/lib/pkgconfig:...gstreamer-1.28.8-dev/...:...alsa-lib-1.2.16.1-dev/... PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 pkg-config --static --libs --cflags libzstd
The system library `libzstd` required by crate `zstd-sys` was not found.

The probe searches exactly the PKG_CONFIG_PATH the package's buildInputs contribute, and that list carries no zstd. One leaf, and every derivation downstream of it with it: the consumer's report was one leaf and 61 dependants.

compare/f4a03c00...52ab070a14e41fae5f6f26d432e264237fd63125 reports ahead — the fix is on master, not yet in the nixos-unstable head that consumer follows. The carry belongs here, in the flake that builds the package: a nixpkgs.overlays entry on the consumer's package set never reaches this derivation, because this flake builds nixpkgs' package through its own import nixpkgs.

Change

buildInputs = (oldAttrs.buildInputs or [ ]) ++ codexSysLibsToCarry; inside the existing overrideAttrs, with codexSysLibs naming the same four attributes upstream adds.

The carry is its own retirement test. nixpkgsCodexCarriesSysLibs reads pkgs.codex.buildInputs — nixpkgs' own package, from the nixpkgs this flake actually evaluates — and codexSysLibsToCarry refuses to evaluate once that package declares all four:

error: nixpkgs' own codex declares aws-lc, oniguruma, sqlite and zstd, so this flake's codexSysLibs carry is redundant

No date, no channel name, no script: a consumer that follows its nixpkgs into this flake — which is what the README tells a NixOS system to do — is gated at the revision it actually consumes rather than at whatever master had merged, and the carry cannot outlive the fix, because keeping it stops the flake from evaluating.

The predicate compares .drvPath rather than .outPath. All four are multi-output packages, and a package set names the dev output in buildInputs while the package value names its first output, so an output-path comparison never matches and the gate looks inert.

Verification

  • Carry active where the fix is absent. At this flake's own nixpkgs (4fe25e12, 2026-11-06): nix eval .#packages.x86_64-linux.codex.buildInputs returns nixpkgs' eight entries plus the carried four.
  • Gate fires where the fix is present. Same flake, unchanged, over a nixpkgs that contains 16b463698a (--override-input nixpkgs github:NixOS/nixpkgs/master, 7d689997): the throw above.
  • nix flake check: all checks passed!; nix fmt is a no-op.
  • Builds at the revision that started this. nix build --option abort-on-warn true --override-input nixpkgs github:NixOS/nixpkgs/f4a03c008967841f2a0b3cb7c436fc6fc31671f6 .#packages.x86_64-linux.codex exits 0, /nix/store/rjvb1nnvkp5q43kgcapc2298jc0lc4ym-codex-0.167.0. That build's derivation is /nix/store/jyrf0fq4nr6wqvpsfv5qnl438v2bwsx8-codex-0.167.0.drv — the same derivation the consumer produced when it carried these four inputs on its own side, which is what makes the two forms interchangeable.
  • Gate. Build and Check run 42748111975: completed / success.
  • The carry does what it claims. Against that output, objdump -p bin/codex lists ten NEEDED entries including libzstd.so.1, libsqlite3.so and libonig.so.5; the same package built without them at the prior revision lists six and none of the three. The derivation's buildInputs carry aws-lc-5.12.0-dev, oniguruma-6.9.10-dev, sqlite-3.54.0-dev and zstd-1.5.7-dev — sqlite at the consumer's version, not this flake's own lock, which confirms a following consumer is served from its own package set.

Consumption

No consumer expression changes: packages.<system>.codex is the same attribute. jgus-org/nix#436 carried this workaround in that root with a script canary; it is superseded by this PR and closed, so the root needs no change of its own and picks this up on its next input refresh.

Comment thread flake.nix Outdated
Comment on lines +63 to +71
# nixpkgs' cargo setup hook exports the "use the system library" switch for every Rust crate that
# accepts one (nixpkgs 44cddf92c432), so codex's crates probe for a C library instead of building the
# vendored one, and nixpkgs' own codex declares none of the four its crates probe: its build dies in
# zstd-sys' build script with "The system library `libzstd` required by crate `zstd-sys` was not
# found". Upstream declares them in nixpkgs 16b463698a, which reaches a nixos channel only after it
# lands on master. Carry the same four inputs meanwhile. The predicate reads the codex that this
# flake's own nixpkgs input builds, so a consumer that follows its nixpkgs in -- which is what the
# README tells a NixOS system to do -- retires the carry at the revision it actually consumes rather
# than at whatever master had merged.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Instead of writing a novel, can you just provide a link to the upstream issue and be done?

nixpkgs' cargo hook makes codex's crates probe for system libraries that its
package does not declare, so the build dies in zstd-sys' build script. Upstream
declares them in NixOS/nixpkgs#584667, which a nixos
channel reaches late.

codexSysLibsToCarry reads the codex built from this flake's own nixpkgs input and
stops evaluating once that package declares all four, so the carry cannot outlive
the fix and a following consumer is gated at the revision it actually consumes.
@jgus-bot
jgus-bot force-pushed the agent/codex-sys-libs branch from c885622 to be49077 Compare November 10, 2026 04:09
Comment thread flake.nix Resolved
Comment thread flake.nix Resolved
Comment thread flake.nix Resolved
Comment thread flake.nix Resolved
@jgus
jgus merged commit b475b07 into main Nov 10, 2026
1 check passed
@jgus
jgus deleted the agent/codex-sys-libs branch November 10, 2026 05:50
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.

2 participants