fix(nix): apply the repository cargo config to Nix builds - #1496
Conversation
`.cargo/config.toml` sets 47 `SQLITE_OMIT_*` values, and sqlite3-src's build script turns every `SQLITE_*` environment variable into a `-D` define for the bundled amalgamation. Cargo only reads that file when the working directory is the repository root, so it applied to local `cargo` runs and to nothing else: every Nix build, including the shipped binaries, compiled the full SQLite. Reading the same file in package.nix rather than duplicating the values keeps one source of truth. The aarch64-darwin binary drops 3,232,896 -> 3,030,272 bytes (-6.3%), and the four SQLite-backed adapters produce byte-identical JSON before and after.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough
ChangesCargo environment propagation
Estimated code review effort: 2 (Simple) | ~5 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
ccusage-guide | e399375 | Commit Preview URL Branch Preview URL |
Jul 27 2026, 11:26 AM |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — reads .cargo/config.toml's [env] section into the Nix build so the 47 SQLITE_OMIT_* flags apply uniformly, shrinking the shipped binary by ~6.3% without changing adapter output.
- Read
.cargo/config.tomlintocargoConfigEnv— singlebuiltins.fromTOML+builtins.readFileparse, same path-join pattern as the existingpackage.jsonread on line 14. - Merge into
commonArgsvia//— env vars propagate cleanly through all three build stages (buildDepsOnly, artifact layers,buildPackage).
@v0 or keep the SHA fresh with Dependabot | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
ccusage
@ccusage/ccusage-darwin-arm64
@ccusage/ccusage-darwin-x64
@ccusage/ccusage-linux-arm64
@ccusage/ccusage-linux-x64
@ccusage/ccusage-win32-x64
commit: |
ccusage performance comparisonPR SHA: This compares the PR package against the configured base package on the same CI runner. Package runtime diagnosticsCompares the PR package wrapper, the installed native optional dependency binary, and the workspace release binary on the same large fixture. This identifies whether slow package results come from JavaScript wrapper overhead, the published native binary build, or the Rust core itself. Fixtures: Claude
Committed fixture performanceCommitted small fixtures for stable PR-to-PR feedback and explicit Claude/Codex command coverage. Fixtures: Claude
Large real-world-shaped fixture performanceGenerated fixtures shaped from aggregate local log statistics: thousands of JSONL files, many small sessions, and a long tail of larger sessions. No real prompts, paths, or outputs are stored in the fixtures. Fixtures: Claude
Artifact size
Lower medians and smaller artifacts are better. CI runner noise still applies; use same-run ratios as directional PR feedback, not release guarantees. |
ccusage performance comparisonPR SHA: This compares the Rust PR release binary against the configured base package on the same CI runner. Package runtime diagnosticsCompares the PR package wrapper, the installed native optional dependency binary, and the workspace release binary on the same large fixture. This identifies whether slow package results come from JavaScript wrapper overhead, the published native binary build, or the Rust core itself. Fixtures: Claude
Committed fixture performanceCommitted small fixtures for stable PR-to-PR feedback and explicit Claude/Codex command coverage. Fixtures: Claude
Large real-world-shaped fixture performanceGenerated fixtures shaped from aggregate local log statistics: thousands of JSONL files, many small sessions, and a long tail of larger sessions. No real prompts, paths, or outputs are stored in the fixtures. Fixtures: Claude
Artifact size
Lower medians and smaller artifacts are better. CI runner noise still applies; use same-run ratios as directional PR feedback, not release guarantees. |

Summary
.cargo/config.tomlsets 47SQLITE_OMIT_*values in its[env]section, andsqlite3-src's build script turns everySQLITE_*environment variable into a-Ddefine for the bundled amalgamation. That is how this repository trims SQLite down to
what the four SQLite-backed adapters actually use.
Cargo only reads that file when the working directory is the repository root, so it
applied to local
cargoruns and to nothing else. Every Nix build unpacks a sourcetree rooted at
rust/, so all of them — the artifact layers, the flake checks, andthe binaries the release ships — compiled the full SQLite.
package.nix now reads the same file rather than duplicating the values, so there is
still one source of truth and the two cannot drift.
Effect
−202,624 bytes, −6.3%, on the aarch64-darwin Nix build. For scale, that is more than
the whole size cost of the crate split in #1428.
Correctness
The omit flags remove SQLite features, so the risk is a query needing one of them.
These values already applied to every local
cargo testrun, which is what exercisesthe adapters' queries, but never to a Nix-built binary — so this is the first time a
shipped binary would carry them. Checked directly by diffing the old and new Nix
binaries against real local data:
opencode daily --json --offline— identicalgoose daily --json --offline— identicalkilo daily --json --offline— identicalhermes daily --json --offline— identicaldaily --json --offline(unified) — identicalTesting
nix build .#ccusage .#ccusage-tests .#checks.aarch64-darwin.ccusage-clippy .#checks.aarch64-darwin.config-schemajust fmtFound while reviewing the diff of #1428; the condition predates it.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is enabled.Summary by cubic
Apply the repository
.cargo/config.toml[env]to Nix builds soSQLITE_OMIT_*flags fromsqlite3-srcare honored, matching local cargo builds. Shipped binaries shrink by 202,624 bytes (-6.3% on aarch64-darwin) with identical adapter JSON outputs, and the flags now come from a single source of truth.Written for commit e399375. Summary will update on new commits.
Summary by CodeRabbit