Skip to content

Commit e399375

Browse files
committed
fix(nix): apply the repository cargo config to Nix builds
`.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.
1 parent 60f1984 commit e399375

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

‎package.nix‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ let
2323
|| lib.hasSuffix "/models-dev-pricing.json" path
2424
|| lib.hasSuffix "/codex-auto-review-fallbacks.json" path;
2525
};
26+
# sqlite3-src's build script turns every SQLITE_* environment variable into a -D
27+
# define for the bundled amalgamation, which is how .cargo/config.toml trims it.
28+
# Cargo only reads that file when the working directory is the repository root, and
29+
# no Nix build has that, so the same values are passed through here rather than
30+
# duplicated.
31+
cargoConfigEnv = (builtins.fromTOML (builtins.readFile (root + /.cargo/config.toml))).env;
2632
commonArgs = {
2733
pname = "ccusage";
2834
inherit version src;
@@ -54,7 +60,8 @@ let
5460
buildInputs = lib.optionals stdenv.isDarwin [
5561
apple-sdk_15
5662
];
57-
};
63+
}
64+
// cargoConfigEnv;
5865
# Keep the dependency artifact keyed only by inputs that affect Cargo deps.
5966
# Pricing snapshots and the npm release version are embedded by the final
6067
# package. The Rust workspace packages intentionally stay at 0.0.0, and the

0 commit comments

Comments
 (0)