ci(rust): cache cargo build + Nix store (cachix) - #107
Merged
Conversation
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.
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
force-pushed
the
ci/cache-rust-nix
branch
from
June 22, 2026 17:40
9d22661 to
4acb8db
Compare
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.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The nix
rustCI 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:actions/cacheover~/.cargo/{registry,git}+target/) — the dominant cost.clippy --all-targets+test+codegenrecompiled hundreds of crates (tauri, specta, webkit bindings) every run; restoringtarget/makes it incremental. Keyed onflake.lock(toolchain pin) +Cargo.lock, with restore-keys so a lock bump reuses the previoustarget.cachix/cachix-action, public cachekasumi-proxy) — replaces the retiredmagic-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 theCACHIX_AUTH_TOKENsecret.The devshell sets no
CARGO_HOME/CARGO_TARGET_DIR(verified), so~/.cargo+./targetare what cargo actually uses insidenix develop.Measured (on this branch, real CI runs)
≈ 5× faster, ~9 min saved per warm run. A CI-config-only change doesn't trigger the
rustjob (path filter), so the warm number was measured with a throwaway rust edit on this branch (reverted — the merged diff isci.ymlonly).Affected layer
.github/Verification
actionlint .github/workflows/ci.ymlcleanCARGO_HOME/CARGO_TARGET_DIRunset)Notes for reviewers
kasumi-proxyis public (managed signing, zstd compression). TheCACHIX_AUTH_TOKENsecret is set on the repo for pushes; reads are token-free.nix developclosure), the cargo cache caches the compiled Rust (target/).actions/cacheSHA reused fromrelease.yml;cachix/cachix-actionpinned to the v17 commit.