cachix-action

April 2, 2026 ยท View on GitHub

CI

Nix enables Continuous Integration (CI) to build and cache developer environments for every project and branch using binary caches. With Cachix, you can significantly reduce build times by ensuring packages are built only once and shared across all developers and CI runs.

After each job, newly built packages are pushed to your binary cache. Before each job, packages to be built are first downloaded (if they exist) from your binary cache.

Tutorial

Follow the long-form tutorial on Continuous Integration with GitHub Actions from nix.dev.

Examples

Read-only cache

- uses: cachix/cachix-action@v17
  with:
    name: mycache

Write cache with auth token

- uses: cachix/cachix-action@v17
  with:
    name: mycache
    authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"

Write cache with signing key

- uses: cachix/cachix-action@v17
  with:
    name: mycache
    authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
    signingKey: "${{ secrets.CACHIX_SIGNING_KEY }}"

Options

Cache Configuration

InputDescriptionRequiredDefault
nameName of the Cachix cache to pull (substitute) from and optionally push toโœ“
extraPullNamesComma-separated list of additional Cachix cache names to pull (substitute) from

Authentication

InputDescriptionRequiredDefault
authTokenAuthentication token for Cachix, required for private cache access or to push to any cache
signingKeyPrivate signing key for self-signed caches, used in addition to the auth token to sign store paths

Push Configuration

InputDescriptionRequiredDefault
skipPushSet to true to only pull from the cache without pushing any build resultsfalse
useDaemonUse Cachix daemon mode to push store paths as they're built via post-build hooks. See Push modes for more informationtrue
pathsToPushWhitespace-separated list of specific store paths to push. Leave empty to push all build results
pushFilterRegular expression to exclude derivations from being pushed, for example "(-source$ | nixpkgs\.tar\.gz$)". Ignored if pathsToPush is set. Warning: paths may still be pushed if they are part of another path's closure

Advanced Options

InputDescriptionRequiredDefault
skipAddingSubstituterSet to true to skip adding the cache as a Nix substituterfalse
cachixArgsAdditional command-line arguments to pass to Cachix commands. Defaults to -j8 for parallel processing
cachixBinCustom path to the Cachix binary if not using the default installation
installCommandCustom command to install Cachix instead of the default installation method

Push modes

The action can push in two modes: daemon mode with post-build hooks and store scan. This can be controlled with the useDaemon option.

Daemon mode (default)

The daemon registers a post-build hook with Nix. Newly built store paths are pushed to the cache as they're built. The limitation is that Nix does not trigger the hook for substituted paths.

Note

Post-build hooks may be run as root if the nix-daemon is root. This can lead to unexpected privilege escalation if you run untrusted code. For common CI scenarios (hosted GitHub Actions), this is typically not an issue, but you should evaluate the risks for your infrastructure.

Follow https://github.com/NixOS/nix/issues/5208 for updates on non-root nix-daemon support.

Store scan mode

The store scan method looks for differences in the store at the file system level. It will capture all store paths, including those substituted.

Note

This is not a safe method for multi-user stores. You can inadvertently upload and leak store paths built by other users. Prefer the daemon mode in such cases.

Security

Cachix tokens and signing keys provide full read and/or write access to your caches.

GitHub Actions allows anyone who can edit workflow files to read secrets.

This means developers with write access can read your secrets and access your cache.

Forked pull requests cannot access secrets, so they can only read from public caches.

Malicious code merged from forks can reveal your tokens.

Contributing

See CONTRIBUTING.md.