Pushing to Cachix

There are different ways to push store paths to Cachix.

Pushing runtime dependencies

$ nix-build | cachix push mycache

Pushing build and runtime dependencies

$ nix-store -qR --include-outputs $(nix-store -qd $(nix-build)) \
  | grep '\.drv$' \
  | cachix push mycache

Pushing shell environment

$ nix-build shell.nix -A inputDerivation \
  | cachix push mycache

Pushing whole /nix/store

$ nix path-info --all | cachix push mycache

Pushing all newly built store paths

$ cachix watch-store mycache

Push all store paths produced during a command

$ cachix watch-exec mycache nix-build -- --max-jobs 4

Flakes

Assuming you’re familiar with experimental Flakes support.

Pushing flake inputs

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

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

Pushing runtime closure

To push runtime closure of all packages in a Flake:

$ nix build --json \
  | jq -r '.[].outputs | to_entries[].value' \
  | cachix push mycache

Pushing shell environment

$ nix develop --profile dev-profile
$ cachix push mycache dev-profile