Skip to content

pkgs/id: split dependency compilation out of the Nix build with crane (#8574) - #12863

Merged
dezren39 merged 1 commit into
mainfrom
archer-lane-be/8574-crane
Nov 23, 2026
Merged

dezren39 merged 1 commit into
mainfrom
archer-lane-be/8574-crane

Conversation

@dezren39

@dezren39 dezren39 commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Closes #8574. Follow-up to #8392; pattern proven by #8560 (atlas-search) and #8572 (fleet).

What changed

pkgs/id/default.nix: the single buildRustPackage becomes the crane two-tier shape.

  • Deps tier (craneLib.buildDepsOnly → the id-deps derivation): a fileset of Cargo.toml, Cargo.lock, crates/, src/, vendor/, build.rs, .cargo/ — crane stubs the workspace members' Rust targets in this tier, so it is keyed only on what can change dependency compilation. Vendored path deps compile for real here.
  • Package tier (craneLib.buildPackage): src = ./. — the full tree, exactly what the monolith saw (tests read test-data/, the root build.rs checks web/dist). Same features (sandbox,world), same doCheck, same postCheck fmt + clippy.
  • craneLib ? null argument like the reference PRs; since this file's only in-repo use is standalone nix-build, a null argument constructs craneLib from the pinned crane rev the repo flakes already carry (01bc1d404a51a0a07e9d8759cd50a7903e218c82) so the split is live on the documented path.
  • Crane API differences handled: lockfile passed as a path; outputHashes is a separate argument keyed by the lockfile's full git source string (same p2panda checkout hash as the monolith's p2panda-core-0.7.1 entry).
  • The standalone check derivation is byte-identical to before (verified by diff of the section) and still instantiates (id-check-0.1.0.drv).
  • One behaviour note: tests run under the release profile in the crane path (crane reuses the dependency artifacts in the check phase) instead of the monolith's ci-check checkType.

Evidence

  • Dry-run oracle (acceptance 1): with the deps output in the store (/nix/store/wmij8f8panyay1i9bfmp5npb5x2ffsgr-id-deps-0.1.0), a one-line change to crates/id-core/src/lib.rs makes nix-build -A default --dry-run list only the package derivation (id-0.1.0.drv) — the id-deps derivation is untouched.
  • Build equivalence: both the monolith baseline and the crane build fail on exactly one test — the pre-existing main failure cli::tests::test_command_lists_cover_all_clap_subcommands ("README CLI Commands table omits walk", id-cli 743 passed / 1 failed), filed separately as id-cli test failing on main: README CLI Commands table omits walk #12772. All other suites green in both. This PR neither fixes nor worsens it; once id-cli test failing on main: README CLI Commands table omits walk #12772 lands, this build goes green with no further change.
  • Timings (reference laptop, both under concurrent load): monolith baseline 45m16s; first crane build 94m40s (deps tier's build+check+test passes plus release-profile test compilation, under heavier load than the baseline). The split's payoff is in rebuilds, per the oracle above.
  • nixfmt --check clean on the file.

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

…#8574)

Convert pkgs/id/default.nix from a single buildRustPackage to the crane
two-tier shape proven by atlas-search (#8560) and fleet (#8572):
buildDepsOnly compiles the registry + vendored dependencies as their
own derivation (id-deps), keyed only on the manifests and Cargo.lock
with the workspace sources stubbed, and buildPackage builds the
workspace against those artifacts from the full source tree. A one-line
source change now rebuilds only the package derivation (dry-run
verified: only the id-0.1.0 package derivation is listed; the id-deps
derivation is untouched).

Notes:
- Callers may pass craneLib; standalone nix-build constructs one from
  the pinned crane rev the repo flakes already carry
  (01bc1d404a51a0a07e9d8759cd50a7903e218c82).
- Crane takes the lockfile as a path and outputHashes as a separate
  argument, keyed by the lockfile's full git source string instead of
  crate name-version (same p2panda checkout, same hash).
- The standalone check derivation (~line 82) is unchanged byte for
  byte and still instantiates; the package-root build.rs is stubbed by
  crane in the deps tier and runs for real in the package tier, whose
  source is the full tree exactly as the monolith saw it.
- Tests run under the release profile in the crane path (crane reuses
  the dependency artifacts for the check phase) instead of the
  monolith's ci-check checkType.

Timings on the reference laptop (both builds red only on the
pre-existing #12772 failure, with an identical failure set - id-cli
743 passed / 1 failed): monolith baseline 45m16s; first crane build
94m40s (the deps tier's build+check+test passes and release-profile
test compilation, under heavy concurrent load). The split's payoff is
in rebuilds: the deps derivation is untouched by source changes.
@dezren39
dezren39 requested a review from a team as a code owner November 23, 2026 04:02
@coderabbitai

coderabbitai Bot commented Nov 23, 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 28 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: 8cdf1634-12dd-4da5-8879-d04d77eb7e8c
Commits

Reviewing files that changed from the base of the PR and between dfeaaf5 and 03fe0c2.

Files selected for processing: 1

  • pkgs/id/default.nix
  • 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

@dezren39
dezren39 merged commit ced8e85 into main Nov 23, 2026
2 checks passed
@dezren39
dezren39 deleted the archer-lane-be/8574-crane branch November 23, 2026 04:02
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.

pkgs/id: split dependency compilation out of the Nix build with crane (code#8392 follow-up)

1 participant