Skip to content
Cachix

Pushing to Cachix

There are different ways to push store paths to Cachix.

Replace MY_CACHE with your cache name in the examples below.

A build output can refer to other paths in the Nix store. Together, the output and everything reachable through those references form its runtime closure. cachix push takes a store path or a symlink such as ./result, walks that closure, and uploads the paths missing from the cache and its upstreams.

Terminal window
$ nix-build | cachix push MY_CACHE
Terminal window
$ nix-store -qR --include-outputs $(nix-store -qd $(nix-build)) \
| grep -v '\.drv$' \
| cachix push MY_CACHE
Terminal window
$ nix-build shell.nix -A inputDerivation \
| cachix push MY_CACHE
Terminal window
$ nix path-info --all | cachix push MY_CACHE

Assuming you’re familiar with Flakes.

As flake inputs are downloaded from the internet, they can disappear. Copying them over to Cachix saves you from that day.

Terminal window
$ nix flake archive --json \
| jq -r '.path,(.inputs|to_entries[].value.path)' \
| cachix push MY_CACHE

To push runtime closure of the default package in a Flake:

Terminal window
$ nix build --no-link --print-out-paths \
| cachix push MY_CACHE

To push runtime closure of any set of packages in a Flake:

Terminal window
$ nix build --no-link --print-out-paths .#package-a .#package-b \
| cachix push MY_CACHE

Note: to build all packages, leave a thumbs up on NixOS/nix#7165.

Terminal window
$ nix develop --profile dev-profile -c true
$ cachix push MY_CACHE dev-profile

Use watch-store to watch the store continuously or watch-exec to limit observation to the duration of a command.

Terminal window
$ cachix watch-store MY_CACHE

Push all store paths produced during a command

Section titled “Push all store paths produced during a command”
Terminal window
$ cachix watch-exec MY_CACHE -- nix-build --max-jobs 4

Daemon command reference

Cache builds in CI