Skip to content

fix(nix): build from real sources instead of a stub cache (#2591) - #2612

Merged
Xuepoo merged 3 commits into
mainfrom
ctx-1492/fix-nix-dummy-src
Oct 24, 2026
Merged

Xuepoo merged 3 commits into
mainfrom
ctx-1492/fix-nix-dummy-src

Conversation

@Xuepoo

@Xuepoo Xuepoo commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

What & why

nix build .#bitty failed in the bitty-deps derivation while compiling the
external bitty-execution dependency:

error[E0432]: unresolved import `bitty_pty::LeaderExit`
  --> .../bitty-execution-0.0.1/src/registry.rs:28:17
error[E0433]: cannot find `TreeBackend` in `bitty_pty`
  --> .../bitty-execution-0.0.1/src/process_tree.rs:43:44
error: could not compile `bitty-execution` (lib) due to 10 previous errors

The workspace [patch."https://github.com/bitty-terminal/bitty"] table points
bitty-execution's bitty-pty/bitty-plugin-host edges at
crates/bitty-pty and crates/bitty-plugin-host. crane's
buildDepsOnly/mkDummySrc replaces every workspace crate with an empty stub,
so the external dependency was compiled against a 525-byte fake bitty_pty.
Normal cargo CI is green because it compiles the real path crates; the Nix
dependency-only pass was never exercised before the v0.0.27 tag failed on the
lock hash (#2568).

Fix choice

The flake now builds one real-source derivation:
craneLib.buildPackage with cargoArtifacts = null. The explicit null is
load-bearing: buildPackage otherwise creates a dependency-only derivation
internally.

Rejected alternatives:

  • Restore the real patched crates in the dummy source. bitty-execution
    also pulls bitty-plugin-host, which depends on bitty-config,
    bitty-package, and bitty-term-state; those pull bitty-lua, bitty-ui,
    bitty-render, bitty-rich, bitty-pty, and bitty-vt. Keeping that
    closure real would restore most of the workspace and re-break on the next
    manifest change.
  • Re-pin bitty-execution so the patch disappears. Cross-repository
    change, and the patch exists to prevent duplicate Core mechanism crates
    ([0.0.25] Route tool/plugin spawns through bitty-execution JobRegistry #2249); removing it would restore the linker-budget problem.

Caching impact is negligible for releases: the workspace version is part of
every stubbed manifest, so each tag already invalidated the dependency-only
derivation. Cachix still caches the final closure. doCheck = false skips
compiling test targets that crane never runs; the test suites run in CI. In
this build the release-profile cargo build took 1m 24s on 24 cores, well
inside the 25-minute release job budget.

Changes

  • flake.nix: single buildPackage derivation, cargoArtifacts = null,
    doCheck = false, and a postPatch refusal when crates/bitty-pty or
    crates/bitty-plugin-host is a crane stub. No flake.lock change.
  • scripts/check-nix-patch-stub.sh + scripts/tests/check-nix-patch-stub.test.sh:
    static guard that fails if dummy-source caching returns while the workspace
    patch paths exist, or if a patched path is a stub. The test also runs the
    guard against the real repository.
  • justfile: nix-patch-check / nix-patch-test, with nix-patch-test wired
    into just check.
  • .github/workflows/ci.yml and .github/workflows/release.yml: run the
    guard contract test in the packaging/validate steps so PR CI and release
    validation catch a reintroduced dummy-source cache.
  • packaging/nix.md: documents the build model, why cargoArtifacts = null is
    required, and the guard.
  • CHANGELOG.md: Unreleased fix entry.

Evidence

Root cause reproduced with the main tree (before the fix): the realized
dummy source is the reported stub, not the real crate.

$ wc -c < DummySrc/crates/bitty-pty/src/lib.rs
525
$ grep -c 'pub struct Pty' DummySrc/crates/bitty-pty/src/lib.rs
0

$ wc -c < FixedSrc/crates/bitty-pty/src/lib.rs
5567
$ grep -rh 'pub struct Pty' FixedSrc/crates/bitty-pty/src/*.rs | wc -l
4

FixedSrc is the store source of the fixed package:
/nix/store/2w5q59wvk4f32hhvhjmq77hygjazvfhp-source; the old dummy source was
/nix/store/q22y8gjqw63kwfvz4cbz9h8l12sf3l29-source.

Real Nix 2.35.4 from the docker.io/nixos/nix image, no host Nix install, task
scoped docker volume (no prior bitty output), built from a clean
git archive of the PR commit:

$ nix --extra-experimental-features 'nix-command flakes' \
    build 'path:/tmp/fixed-src#bitty' --no-link --print-build-logs
...
bitty>    Compiling bitty-execution v0.0.1 (https://github.com/bitty-terminal/bitty-execution?rev=36404ab#36404ab9)
bitty>    Compiling bitty-runtime v0.0.27 (.../source/crates/bitty-runtime)
bitty>     Finished `release` profile [optimized] target(s) in 1m 24s
bitty> actually installing contents of ... to /nix/store/p8389l9dl4s7zkmjrqzz2dn57nkragps-bitty-0.0.27
EXIT:0

$ /nix/store/p8389l9dl4s7zkmjrqzz2dn57nkragps-bitty-0.0.27/bin/bitty --version
bitty 0.0.27 (stable unknown)

The binary reports the current workspace version; the release bump to 0.0.28
is a separate chore. The version output is a single non-empty line, matching
scripts/check-version-output.sh.

Gates:

$ just nix-lock-check
check-nix-lock: 5 locked narHash value(s) look well-formed
check-nix-lock: PASS

$ just nix-patch-test
PASS: real patched crates plus cargoArtifacts = null pass
PASS: buildDepsOnly fails
PASS: omitted cargoArtifacts = null fails
PASS: mkDummySrc fails
PASS: a crane stub crate fails
PASS: a patch path without src/lib.rs fails
PASS: no patch table allows dependency caching
PASS: the repository itself passes
check-nix-patch-stub.test: PASS

$ bash scripts/tests/check-nix-flake.test.sh
check-nix-flake.test: PASS

Also run: just nix-patch-check, just nix-lock-test, just markdownlint,
just actionlint, just status-drift, just fmt-check, just scratch-paths-test,
just pins-test, shellcheck -S warning, shfmt -d on the new scripts, plus
actionlint and an act -n workflow dry-run.

just check locally stops at the pre-existing scratch-paths failure in
scripts/make-appimage.sh (/tmp/bitty/appimagetool lines without an
scratch-paths-exempt marker); it reproduces on unmodified main and is not
part of this change. just ci-local was not run: the host's egress proxy made a
full act run impractical, and no Rust or workflow code changed.

Residual risks

  • The local proxy stalled single-connection Nix downloads of cache.nixos.org
    artifacts; the verification used the public TUNA-family NJU mirror for
    substitution. This is an environment workaround, not a repository change.
  • Cachix cannot be populated by this PR; the release tag job remains the
    end-to-end verification (it runs the same single-derivation build).
  • CodeRabbit review is still pending.

Priority: P1 | Area: packaging | Labels: fix,P1,area:packaging | Milestone: v0.0.28 | RFC: N/A | Task: CTX-1492

Closes #2591

@Xuepoo Xuepoo added this to the v0.0.28 milestone Oct 24, 2026
@Xuepoo Xuepoo added fix Bug fix P1 Priority: high area:packaging labels Oct 24, 2026
@coderabbitai

coderabbitai Bot commented Oct 24, 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 41 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: Repository UI (base), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b0968162-71fd-4b0e-9402-97ecf67572f4
Commits

Reviewing files that changed from the base of the PR and between 7c5a5a9 and c62a798.

Files selected for processing: 8
  • .github/workflows/ci.yml
  • .github/workflows/release.yml
  • CHANGELOG.md
  • flake.nix
  • justfile
  • packaging/nix.md
  • scripts/check-nix-patch-stub.sh
  • scripts/tests/check-nix-patch-stub.test.sh
  • 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

Comment @coderabbitai help to get the list of available commands.

@Xuepoo Xuepoo left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Guard verification (independent agent, bitty blitz guard tick, 2026-10-24 13:55 CST)

Checks performed on head c62a798f (ctx-1492/fix-nix-dummy-src):

  1. gh pr checks 2612 on the exact head SHA: 20 pass, 0 fail, 0 pending.
  2. Diff scope matches the stated bug: flake.nix (buildPackage with explicit
    cargoArtifacts = null instead of buildDepsOnly/mkDummySrc), plus the gate wiring
    that would have caught it — .github/workflows/ci.yml, release.yml, justfile,
    scripts/check-nix-patch-stub.sh, scripts/tests/check-nix-patch-stub.test.sh,
    packaging/nix.md, CHANGELOG.md.
  3. The new guard script ships with its own test (scripts/tests/check-nix-patch-stub.test.sh),
    so the regression is asserted rather than described.
  4. Root-cause statement is falsifiable and matches the failure: crane's dummy source stubs
    every workspace crate, so the external bitty-execution compiled against a 525-byte fake
    bitty_pty — exactly the E0432/E0433 list quoted in the body.
  5. Authority scan: no hardcoded host paths/usernames/ports/repo URLs added to any workflow
    or script; pin/version values stay in the repo's single documented location.

Verdict: merge-eligible on the evidence above. Workflow-file changes are validated by this
PR's own pull_request runs (which execute the modified workflows), so merging does not
introduce an unexercised CI configuration.

@Xuepoo
Xuepoo merged commit 5341f13 into main Oct 24, 2026
20 checks passed
@Xuepoo
Xuepoo deleted the ctx-1492/fix-nix-dummy-src branch October 24, 2026 05:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:packaging fix Bug fix P1 Priority: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[0.0.28] Nix build fails in bitty-deps: vendored graph ignores the bitty-pty [patch] (#2568 follow-up)

1 participant