Skip to content
kasha

Push from a client

A local build can go to the box instead of waiting for CI: push the signed closure with nix copy, then publish a manifest through the same authenticated API. The box mirrors the generation up to the remote cache in the background.

  • The box’s write token (KASHA_TOKEN on the box).
  • A signing key whose public half is in the box’s KASHA_TRUSTED_KEYS. The box never signs: it rejects any narinfo that has neither a trusted signature nor a CA field reproducing its store path.
  • The kasha binary, for kasha emit.

The box accepts Authorization: Bearer <token> or HTTP Basic auth with any login and the token as password. nix copy sends Basic auth from a netrc file:

Terminal window
echo 'machine box.lan login nix password <token>' > ~/.config/nix/netrc

Point Nix at the file with netrc-file in nix.conf, or pass --option netrc-file per command. A write without a valid token gets 401.

Terminal window
nix store sign --key-file ./secret-key --recursive ./result
nix copy --to 'http://box.lan:5000?compression=zstd' ./result

compression=zstd overrides Nix’s xz default. The box stores and serves NARs as they arrive, and mirror-up copies them to the remote cache unchanged, so every machine that later substitutes the path decodes what you chose here, and zstd decodes about ten times faster than xz. A box with KASHA_REENCODE on re-encodes an xz push as zstd after the fact, and before mirror-up uploads it; zstd from the start saves it that work.

--recursive signs the whole closure. A path signed only by keys the box does not trust is refused with neither a trusted signature nor a valid content address on /nix/store/….

Without a manifest the box holds the paths but never mirrors them up. Emit one to the box, listing the closure you pushed:

Terminal window
nix-store --query --requisites ./result \
| KASHA_TOKEN=<token> kasha emit --flake znix --gen "$gen" \
--branch main --attr host --to http://box.lan:5000

The box stores the manifest at roots/<flake>/<gen>.json only when its flake and gen fields match that path, and marks the generation local-origin.

On each sync cycle the box copies every path of a local-origin generation that the remote cache lacks, NAR before narinfo, then uploads the manifest last. Until that succeeds the generation counts in pending_mirror_up:

Terminal window
curl -s http://box.lan:5000/status

Mirror-up waits while any listed path is missing on the box (logged as mirror-up deferred), so push the closure before, or together with, the manifest.

A local-origin generation is never garbage-collected by the box until mirror-up has uploaded its manifest to the remote cache. After that it follows the remote’s retention like any other generation.

--branch main puts the generation in the long retention tier. For work in progress, use your branch name so it does not displace reviewed main generations; see Retention and GC.