Every founding pushes the whole nixpkgs SOURCE tree (205 MB, unsigned) from the operator's laptop to the gateway — it is in the runtime closure via /etc/nix/registry.json and clan-cli #1803

Closed
opened 2026-09-23 22:02:49 +00:00 by ben · 2 comments
Owner

Proven (cold manual founding #2 of whakatohea-demo, 2026-09-23 17:00 NZST, build ff4a5263, rented 8 GB DO syd1 134.199.167.181)

The install-phase copy (internal/clan/enrollment.go:1345, nix copy --no-check-sigs --substitute-on-destination --to ssh-ng://root@… <toplevel>) is doing what #699/#1764 intend — the gateway substitutes the stock paths itself. Splitting the gateway system closure …-nixos-system-gateway-26.11.20260612.173d0ad with nix path-info -r --json by signatures:

signed (gateway fetches from cache.nixos.org): 698 paths  1.85 GB
UNSIGNED (the laptop must push):               207 paths  354.0 MB

The unsigned set, largest first:

 205.5 MB  source            ← nixpkgs itself: pkgs/ 431M, nixos/ 32M, lib/, doc/, maintainers/, flake.nix "A collection of packages for the Nix package manager"
  50.4 MB  sops-install-secrets-0.0.1
  48.3 MB  caddy-2.11.4      (ours — vendored plugins)
  28.1 MB  initrd-linux-6.18.35
   8.6 MB  python3.12-keri-1.2.13
   5.1 MB  system-path

nix-store --query --referrers /nix/store/lr5ld8f0qbyhjx3nr9mxfvg4cndvpggp-source:

etc-nix-registry.json
clan-cli
clan-runtime

Measured link during the copy (ss -tin): ~325 KB/s sustained from the laptop → the 354 MB leg is ~18 minutes of a founding, and 58 % of it is nixpkgs source text. Nothing in our own modules sets it — grep -rn 'nix.registry\|nixPath' --include=*.nix over the fleet finds only comments in flake.nix — so it is clan-core's NixOS module pinning nix.registry.nixpkgs.flake = nixpkgs (a path pin, which makes the source a runtime dependency of /etc/nix/registry.json) plus clan-cli's own reference to the nixpkgs source it evaluates against.

The same path will be in every device's closure too (VM mode, home devices) — the same 205 MB over the same home line, per device.

Fix (either alone helps; both are needed to get the path out of the wire entirely)

  1. Pin the registry by reference, not by path. In the gateway (and device) module set nix.registry.nixpkgs.to = { type = "github"; owner = "NixOS"; repo = "nixpkgs"; rev = <the flake's locked rev>; } (from inputs.nixpkgs.rev/narHash), overriding clan-core's flake = pin. /etc/nix/registry.json then holds a reference and the source leaves the closure by that edge. Verify with nix-store --query --referrers — only clan-cli/clan-runtime should remain.

  2. Let the target fetch the source itself for the edge that remains. The path is content-addressed by the input's narHash, so nix flake prefetch github:NixOS/nixpkgs/<rev> ON THE GATEWAY produces the identical /nix/store/…-source before the copy runs — at datacentre speed from GitHub instead of home-uplink speed from the laptop. The natural home is the #1764 substituteAhead step (internal/clan/adapter.go) and its enrollment twin: before the nix copy, prefetch the flake's locked inputs on the target (nix flake prefetch for each type = github input in flake.lock, pinned by rev+narHash — ADR 0272 §6, exact revision, never latest). Best-effort/fail-open like the rest of substitute-ahead: a miss just means the copy pushes it as today.

Either way, pin it with a test the way deploy_substitute_test.go pins the flag: the gateway toplevel's unsigned closure must not contain a path whose flake.nix description is nixpkgs' — or, simpler, the unsigned byte total of the gateway closure has a ceiling (say 150 MB) that fails the build when crossed, so the next accidental 200 MB cannot land silently.

Out of scope here, noted for ADR 0272's slice

sops-install-secrets (50 MB) and our Caddy (48 MB) are legitimately built here today; they are exactly what the Mātou cache (ADR 0275, #1801) exists to serve, and they move there under #1768's sibling work, not this ticket.

Relates to: #1764, #699, #1765, ADR 0272 §1/§6, ADR 0275, #1801, #1753 (the device's 2.6 GB pull — check whether the same source is in it).

## Proven (cold manual founding #2 of `whakatohea-demo`, 2026-09-23 17:00 NZST, build `ff4a5263`, rented 8 GB DO syd1 `134.199.167.181`) The install-phase copy (`internal/clan/enrollment.go:1345`, `nix copy --no-check-sigs --substitute-on-destination --to ssh-ng://root@… <toplevel>`) is doing what #699/#1764 intend — the gateway substitutes the stock paths itself. Splitting the gateway system closure `…-nixos-system-gateway-26.11.20260612.173d0ad` with `nix path-info -r --json` by `signatures`: ``` signed (gateway fetches from cache.nixos.org): 698 paths 1.85 GB UNSIGNED (the laptop must push): 207 paths 354.0 MB ``` The unsigned set, largest first: ``` 205.5 MB source ← nixpkgs itself: pkgs/ 431M, nixos/ 32M, lib/, doc/, maintainers/, flake.nix "A collection of packages for the Nix package manager" 50.4 MB sops-install-secrets-0.0.1 48.3 MB caddy-2.11.4 (ours — vendored plugins) 28.1 MB initrd-linux-6.18.35 8.6 MB python3.12-keri-1.2.13 5.1 MB system-path ``` `nix-store --query --referrers /nix/store/lr5ld8f0qbyhjx3nr9mxfvg4cndvpggp-source`: ``` etc-nix-registry.json clan-cli clan-runtime ``` Measured link during the copy (`ss -tin`): ~325 KB/s sustained from the laptop → the 354 MB leg is ~18 minutes of a founding, and **58 % of it is nixpkgs source text**. Nothing in our own modules sets it — `grep -rn 'nix.registry\|nixPath' --include=*.nix` over the fleet finds only comments in `flake.nix` — so it is clan-core's NixOS module pinning `nix.registry.nixpkgs.flake = nixpkgs` (a *path* pin, which makes the source a runtime dependency of `/etc/nix/registry.json`) plus `clan-cli`'s own reference to the nixpkgs source it evaluates against. The same path will be in every device's closure too (VM mode, home devices) — the same 205 MB over the same home line, per device. ## Fix (either alone helps; both are needed to get the path out of the wire entirely) 1. **Pin the registry by reference, not by path.** In the gateway (and device) module set `nix.registry.nixpkgs.to = { type = "github"; owner = "NixOS"; repo = "nixpkgs"; rev = <the flake's locked rev>; }` (from `inputs.nixpkgs.rev`/`narHash`), overriding clan-core's `flake =` pin. `/etc/nix/registry.json` then holds a reference and the source leaves the closure by that edge. Verify with `nix-store --query --referrers` — only `clan-cli`/`clan-runtime` should remain. 2. **Let the target fetch the source itself for the edge that remains.** The path is content-addressed by the input's `narHash`, so `nix flake prefetch github:NixOS/nixpkgs/<rev>` ON THE GATEWAY produces the identical `/nix/store/…-source` before the copy runs — at datacentre speed from GitHub instead of home-uplink speed from the laptop. The natural home is the #1764 `substituteAhead` step (`internal/clan/adapter.go`) and its enrollment twin: before the `nix copy`, prefetch the flake's locked inputs on the target (`nix flake prefetch` for each `type = github` input in `flake.lock`, pinned by rev+narHash — ADR 0272 §6, exact revision, never latest). Best-effort/fail-open like the rest of substitute-ahead: a miss just means the copy pushes it as today. Either way, pin it with a test the way `deploy_substitute_test.go` pins the flag: the gateway toplevel's unsigned closure must not contain a path whose `flake.nix` description is nixpkgs' — or, simpler, the unsigned byte total of the gateway closure has a ceiling (say 150 MB) that fails the build when crossed, so the next accidental 200 MB cannot land silently. ## Out of scope here, noted for ADR 0272's slice `sops-install-secrets` (50 MB) and our Caddy (48 MB) are legitimately built here today; they are exactly what the Mātou cache (ADR 0275, #1801) exists to serve, and they move there under #1768's sibling work, not this ticket. Relates to: #1764, #699, #1765, ADR 0272 §1/§6, ADR 0275, #1801, #1753 (the device's 2.6 GB pull — check whether the same `source` is in it).

swarm-claim host=bens-mac-04 run=30980
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=bens-mac-04 run=30980 (automated multi-host claim — lowest live claim id works this ticket)

close-report for #1803 — status success

✅ close-report gates passed — every claim verified against main; issue closed.

envelope
{
  "issue": 1803,
  "status": "success",
  "commits": [
    "65ac06e2"
  ],
  "changed_files": [
    "STATUS.md",
    "internal/clan/adapter.go",
    "internal/clan/enrollment.go",
    "internal/clan/prefetch.go",
    "internal/clan/deploy_prefetch_test.go"
  ],
  "tests": [
    {
      "command": "nix develop .#go-ci -c go test ./internal/clan/ -count=1",
      "exit_code": 0
    },
    {
      "command": "nix develop .#go-ci -c golangci-lint run ./internal/clan/",
      "exit_code": 0
    },
    {
      "command": "nix develop .#go-ci -c gofmt -l internal/clan/prefetch.go internal/clan/deploy_prefetch_test.go",
      "exit_code": 0
    }
  ],
  "criteria": {
    "Let the target fetch the source itself for the edge that remains (fix 2)": "internal/clan/prefetch.go prefetchInputsOnTarget runs `nix flake prefetch --store ssh-ng://<target> github:<owner>/<repo>/<rev>` for each locked github input on the target's own daemon",
    "Home is #1764 substituteAhead and its enrollment twin, before the copy": "adapter.go substituteAhead and enrollment.go copy both call prefetchInputsOnTarget before missingOnTarget",
    "Pinned by rev, exact revision never latest (ADR 0272 §6)": "githubInputsFromLock reads flake.lock's locked.rev; deploy_prefetch_test.go asserts github:NixOS/nixpkgs/<exact-rev>",
    "Best-effort/fail-open like the rest of substitute-ahead": "prefetchInputsOnTarget ignores each verdict and returns early on no/unparseable lock or empty target; TestDeploy_SkipsThePrefetchOnALoopbackSelfDeploy + TestGithubInputsFromLock_ToleratesAnUnparseableOrEmptyLock pin this",
    "Pin it with a test the way deploy_substitute_test pins the flag": "deploy_prefetch_test.go pins the prefetch runs before probe+copy, targets the ssh-ng store, skips non-github sources, and the loopback skip"
  },
  "summary": "Substitute-ahead now prefetches each pinned github flake source on the deploy target before the copy, so nixpkgs' 205 MB unsigned `source` is fetched from GitHub at datacentre speed instead of pushed from the operator's laptop.",
  "blockers": []
}
**close-report** for #1803 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 1803, "status": "success", "commits": [ "65ac06e2" ], "changed_files": [ "STATUS.md", "internal/clan/adapter.go", "internal/clan/enrollment.go", "internal/clan/prefetch.go", "internal/clan/deploy_prefetch_test.go" ], "tests": [ { "command": "nix develop .#go-ci -c go test ./internal/clan/ -count=1", "exit_code": 0 }, { "command": "nix develop .#go-ci -c golangci-lint run ./internal/clan/", "exit_code": 0 }, { "command": "nix develop .#go-ci -c gofmt -l internal/clan/prefetch.go internal/clan/deploy_prefetch_test.go", "exit_code": 0 } ], "criteria": { "Let the target fetch the source itself for the edge that remains (fix 2)": "internal/clan/prefetch.go prefetchInputsOnTarget runs `nix flake prefetch --store ssh-ng://<target> github:<owner>/<repo>/<rev>` for each locked github input on the target's own daemon", "Home is #1764 substituteAhead and its enrollment twin, before the copy": "adapter.go substituteAhead and enrollment.go copy both call prefetchInputsOnTarget before missingOnTarget", "Pinned by rev, exact revision never latest (ADR 0272 §6)": "githubInputsFromLock reads flake.lock's locked.rev; deploy_prefetch_test.go asserts github:NixOS/nixpkgs/<exact-rev>", "Best-effort/fail-open like the rest of substitute-ahead": "prefetchInputsOnTarget ignores each verdict and returns early on no/unparseable lock or empty target; TestDeploy_SkipsThePrefetchOnALoopbackSelfDeploy + TestGithubInputsFromLock_ToleratesAnUnparseableOrEmptyLock pin this", "Pin it with a test the way deploy_substitute_test pins the flag": "deploy_prefetch_test.go pins the prefetch runs before probe+copy, targets the ssh-ng store, skips non-github sources, and the loopback skip" }, "summary": "Substitute-ahead now prefetches each pinned github flake source on the deploy target before the copy, so nixpkgs' 205 MB unsigned `source` is fetched from GitHub at datacentre speed instead of pushed from the operator's laptop.", "blockers": [] } ``` </details>
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/idss#1803
No description provided.