Skip to content

ci(rust): cache cargo build + Nix store (cachix) - #107

Merged
loss-and-quick merged 4 commits into
mainfrom
ci/cache-rust-nix
Jun 22, 2026
Merged

ci(rust): cache cargo build + Nix store (cachix)#107
loss-and-quick merged 4 commits into
mainfrom
ci/cache-rust-nix

Conversation

@loss-and-quick

@loss-and-quick loss-and-quick commented Jun 22, 2026

Copy link
Copy Markdown
Owner

Summary

The nix rust CI job took ~11–12 min because nothing cached cargo's output and the Nix-store cache step was a dead no-op. Two complementary cache layers fix that:

  1. Cargo build cache (actions/cache over ~/.cargo/{registry,git} + target/) — the dominant cost. clippy --all-targets + test + codegen recompiled hundreds of crates (tauri, specta, webkit bindings) every run; restoring target/ makes it incremental. Keyed on flake.lock (toolchain pin) + Cargo.lock, with restore-keys so a lock bump reuses the previous target.
  2. Nix-store cache via Cachix (cachix/cachix-action, public cache kasumi-proxy) — replaces the retired magic-nix-cache (its GHA backend was shut down; it uploaded nothing). Pulls the devshell closure as a substituter and pushes newly-built paths. Reads need no token (public cache → fork PRs benefit); pushes use the CACHIX_AUTH_TOKEN secret.

The devshell sets no CARGO_HOME / CARGO_TARGET_DIR (verified), so ~/.cargo + ./target are what cargo actually uses inside nix develop.

Measured (on this branch, real CI runs)

Run rust job
Baseline (no cache, historical) ~11m47s
Cold (seeds the cache) 15m41s
Warm 2m33s

5× faster, ~9 min saved per warm run. A CI-config-only change doesn't trigger the rust job (path filter), so the warm number was measured with a throwaway rust edit on this branch (reverted — the merged diff is ci.yml only).

Affected layer

  • CI / .github/

Verification

  • actionlint .github/workflows/ci.yml clean
  • Warm-vs-cold timing measured (table above)
  • Cargo cache paths verified against the devshell (CARGO_HOME/CARGO_TARGET_DIR unset)

Notes for reviewers

  • Cachix cache kasumi-proxy is public (managed signing, zstd compression). The CACHIX_AUTH_TOKEN secret is set on the repo for pushes; reads are token-free.
  • Two layers, not redundant: cachix caches the toolchain/env (nix develop closure), the cargo cache caches the compiled Rust (target/).
  • actions/cache SHA reused from release.yml; cachix/cachix-action pinned to the v17 commit.

The nix rust job recompiled the whole workspace (tauri/specta/webkit bindings,
hundreds of crates) every run — ~11 min — because nothing cached cargo's output.
Add actions/cache over ~/.cargo/{registry,git} + target, keyed on flake.lock (the
toolchain pin) + Cargo.lock, with restore-keys so a lock bump reuses the previous
target and recompiles only what changed. The devshell sets no CARGO_HOME /
CARGO_TARGET_DIR, so these host paths are what cargo actually uses.
@github-actions github-actions Bot added ci CI / workflows (.github/) backend Rust core/backend/desktop (crates/, src-tauri/) labels Jun 22, 2026
magic-nix-cache v8 only uploads to FlakeHub (not connected) — its GHA backend was
retired, so it cached nothing. Use our public cachix cache (kasumi-proxy) instead:
pulls the devshell closure as a substituter and pushes newly-built paths. Reads
need no token (public), so fork PRs benefit; pushes use CACHIX_AUTH_TOKEN.
@loss-and-quick loss-and-quick changed the title ci(rust): cache cargo registry + build to cut the ~11 min nix job ci(rust): cache cargo build + Nix store (cachix) — ~11m → ~2.5m Jun 22, 2026
@loss-and-quick loss-and-quick changed the title ci(rust): cache cargo build + Nix store (cachix) — ~11m → ~2.5m ci(rust): cache cargo build + Nix store (cachix) Jun 22, 2026
@loss-and-quick loss-and-quick removed the backend Rust core/backend/desktop (crates/, src-tauri/) label Jun 22, 2026
Explain that nix develop / nix build substitute the toolchain + devshell closure
from the public kasumi-proxy Cachix cache, and how to opt in locally (cachix use).
Note the cargo build cache is CI-only.
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Jun 22, 2026
Add the kasumi-proxy Cachix cache (URL + public key) to flake.nix nixConfig so
nix develop / nix build pull the toolchain + devshell closure from it without each
contributor running `cachix use`. Honoured for trusted users / with
--accept-flake-config (CI already sets it); README documents accepting the flake
config and the prompt-free `cachix use` alternative. Pulls only — CI still pushes
via the auth-token cachix-action.
@loss-and-quick
loss-and-quick merged commit 6bd1c59 into main Jun 22, 2026
9 checks passed
@loss-and-quick
loss-and-quick deleted the ci/cache-rust-nix branch June 22, 2026 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci CI / workflows (.github/) documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant