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.
Prerequisites
Section titled “Prerequisites”- The box’s write token (
KASHA_TOKENon 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 aCAfield reproducing its store path. - The
kashabinary, forkasha emit.
1. Give Nix the token
Section titled “1. Give Nix the token”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:
echo 'machine box.lan login nix password <token>' > ~/.config/nix/netrcPoint 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.
2. Sign and push the closure
Section titled “2. Sign and push the closure”nix store sign --key-file ./secret-key --recursive ./resultnix copy --to 'http://box.lan:5000?compression=zstd' ./resultcompression=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/….
3. Publish the manifest
Section titled “3. Publish the manifest”Without a manifest the box holds the paths but never mirrors them up. Emit one to the box, listing the closure you pushed:
nix-store --query --requisites ./result \ | KASHA_TOKEN=<token> kasha emit --flake znix --gen "$gen" \ --branch main --attr host --to http://box.lan:5000The 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.
4. Watch it mirror up
Section titled “4. Watch it mirror up”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:
curl -s http://box.lan:5000/statusMirror-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.