Skip to main content

What the Runner cache supports

Trunk Runners provides support for the following cache services. Caching is enabled for the entire org with the ability to overwrite cache behavior for each repo. Cache configuration requires admin privileges. See Cache settings for more options.

sccache

When sccache is on, Trunk sets RUSTC_WRAPPER and CARGO_INCREMENTAL=0 for the job. These values replace the values that you set in a workflow-level or job-level env:. A step-level env: still wins.

Bazel

Trunk uses a Bazel result from the cache only when all of its outputs are still in the cache. If an output is missing, Bazel gets a cache miss and builds the target again. A job that runs in a container (container:) does not get the Bazel setup.

Nix

The default Trunk runner image does not include Nix. Install it with a template, or with an installer step such as cachix/install-nix-action or DeterminateSystems/nix-installer-action.
  • Nix uses the shared cache only when the runner user is a trusted Nix user. Both installer actions trust the runner user by default.
  • Your own Nix settings win. If your job sets its own post-build-hook, Trunk does not upload what the job builds.
  • If Nix cannot get a path from the cache, it builds the path from source.
  • Trunk does not cache a single store path that is larger than 2 GiB.
  • A job that runs in a container (container:) does not get the Nix setup.

Overriding cache behavior

Add cache to the runs-on label to override the default cache behavior for that repo:
The cache option changes only actions/cache. Bazel, sccache, and Nix follow your cache settings. cache=trunk does not turn on actions/cache for a repository where the setting is off.

Which entries a job uses

By default, a job uses cache entries from its own branch and from the default branch. A job writes only to its own branch. For Bazel, sccache, and Nix, an admin can let a job also use entries from all branches in the repository. See Which branches a job uses cache from.
A fork pull request gets read-only cache access. A push to your own repository can write to the cache.

Cache Storage Policy

  • Trunk removes an entry that no job used for 7 days.
  • Each repository can keep up to 20 GiB for each tool. When a repository goes over that limit, Trunk removes the least recently used entries first.
  • Bazel’s cache results and their outputs share one 20 GiB limit.
  • Trunk removes a Nix path only when no other path in the cache refers to it.