[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M784SJ9C733C0G2GFXR5EJ5C":3,"skill-same:01M784SJ9C733C0G2GFXR5EJ5C":56},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":35,"commitSha":36,"skillDirectory":37,"forksCount":38,"repositoryHtmlUrl":39,"repositoryHomepageUrl":6,"ownerHtmlUrl":40,"ownerBlogUrl":41,"ownerDescription":6,"updatedAt":42,"install":43,"resources":55},"01M784SJ9C733C0G2GFXR5EJ5C","update-nixos",null,"Use when updating NixOS flake inputs and deploying nixos-infra to all plan.ai servers, including fixing build errors and pushing resulting commits.","planailabs\u002Fnixos-infra","planailabs","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F261949590?v=4","01M784QMNK8YTQBDBX1G4QWPBZ","plan.ai Labs","01M784S1HQN2W6B9ZTXNA7N91T",1,"MIT","https:\u002F\u002Fgithub.com\u002Fplanailabs\u002Fnixos-infra\u002Fblob\u002Ftrunk\u002F.claude\u002Fskills\u002Fupdate-nixos\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: update-nixos\ndescription: Use when updating NixOS flake inputs and deploying nixos-infra to all plan.ai servers, including fixing build errors and pushing resulting commits.\nversion: 1.1.0\nauthor: plan.ai\nlicense: MIT\nmetadata:\n  hermes:\n    tags: [nixos, infrastructure, deploy, flake-update]\n    related_skills: []\nuser_invocable: true\n---\n\n# Update NixOS Infrastructure\n\n## Overview\n\nThis skill updates the nixos-infra flake inputs, deploys the resulting NixOS configurations to all servers, fixes build errors when possible, commits any fixes, and pushes the result.\n\nRun commands from the repository root.\n\n## When to Use\n\nUse this skill when the user asks to:\n\n- update NixOS\n- update or upgrade nixos-infra\n- update flake inputs\n- deploy the updated NixOS infrastructure\n- run the infra update workflow\n\nThis is also the skill behind the nightly, unattended update run. That run is\nexpected to be a quiet no-op on most days:\n\n- Check whether anything actually moved *before* rewriting `flake.lock`\n  (`nix flake update --dry-run`, or compare `nix flake metadata --json` input\n  revs against the locked revs).\n- If every input is already current, stop: report `nothing to update`. Do not\n  deploy, commit or push.\n- If inputs moved (or the dry run can't tell you, which is itself a reason to\n  look), continue with the full workflow below.\n\nRun fully autonomously when invoked as the nightly job — nobody is watching, so\ndo not ask for confirmation mid-run. Never leave production broken silently: if a\nserver is still failing after the 3 fix attempts, or you conclude you cannot fix\nit, message the person while the run is still going (server name, last real\nerror, the repo\u002Finput you traced it to) and then carry on with the remaining\nservers rather than aborting the run.\n\n## Step 1: Update flake inputs\n\nRun:\n\n```bash\nnix flake update\n```\n\nWait for it to complete. If it fails, diagnose the failure and report it to the user.\n\nAfter `nix flake update` succeeds, commit the updated `flake.lock` using the conventional commit message below:\n\n```bash\ngit add flake.lock\ngit commit -m 'chore: update flake inputs'\n```\n\n## Step 2: Deploy servers in batches of 3\n\nDeploy servers in batches of at most 3 in parallel. Within each batch, launch each deploy script directly as a background shell process from the repository root. Wait for every process in the batch to complete, then inspect all output before starting the next batch.\n\nDo not delegate deploys to subagents or external agent workers. Long-running deploy scripts can outlive delegated agent contexts; run the deploy scripts directly from the shell.\n\n### Every server gets deployed\n\n**Every deploy script in the repository root is part of this workflow.** Deploy the whole list below, every run — not just the ones named here, and not just the ones that succeeded last time. A host that was broken yesterday must be tried again today.\n\nThe full list is everything matching `*.sh` in the repository root that wraps `nixos-rebuild`, i.e. every script except `update.sh`, `reinstall-*.sh`, `sd-image.sh`, `incus-image.sh` and `export-incus.sh`. Before you start, take stock so the list can never silently shrink:\n\n```bash\nfor f in *.sh; do\n  case \"$f\" in reinstall-*|sd-image.sh|incus-image.sh|export-incus.sh|update.sh) continue;; esac\n  grep -l nixos-rebuild \"$f\"\ndone\n```\n\nCross-check that against the flake's `nixosConfigurations`:\n\n```bash\ngrep -E '^      [a-z0-9-]+ = nixpkgs' flake.nix\n```\n\nEvery configuration in the flake should either have a deploy script here or be a deliberate exception (currently `deploy`, which is the CI\u002Fdeploy-host configuration itself). If you add a server to the flake, add its deploy script here and add it to this list. If you find a deploy script not in this list, deploy it anyway and add it here.\n\n### Deploy scripts\n\n| Script | Target | Notes |\n|---|---|---|\n| `sh chronos.sh` | chronos.plan.ai | via port 22222 |\n| `sh logos.sh` | logos.plan.ai | |\n| `sh atlas.sh` | atlas.plan.ai | `boot`, not `switch` |\n| `sh aarch64.sh` | aarch64.plan.ai | needs a remote builder, see below |\n| `sh omen.sh` | omen.plan.ai | `exec sh odysseus.sh` |\n| `sh odysseus.sh` | omen.plan.ai | same host, config `odysseus`; `boot` |\n| `sh peira.sh` | peira.plan.ai | |\n| `sh metis.sh` | metis.plan.ai | |\n| `sh obsidian.sh` | obsidian.plan.ai | |\n| `sh agency.sh` | agency.plan.ai | |\n| `sh relay.sh` | relay.plan.ai | |\n| `sh peira-relay.sh` | relay.peira.plan.ai | |\n| `sh charon.sh` | 49.12.9.126 | plain IP, not a hostname |\n| `sh uptime.sh` | uptime.plan.ai | |\n| `sh scanner.sh` | 150.40.117.230 | plain IP; hosts the rustnmap API |\n| `sh mmrcd.sh` | mmrcd.plan.ai | |\n| `sh cloud-images.sh` | cloud-images.plan.ai | |\n| `sh hippocampus.sh` | hippocampus.plan.ai | |\n| `sh hugger.sh` | hugger-omen.plan.ai | lives on the omen box |\n| `sh hugger-amo.sh` | hugger-amo.plan.ai | |\n| `sh hugger-hetzner.sh` | hugger-hetzner.plan.ai | |\n| `sh hyperion.sh` | hyperion.plan.ai | `boot`, not `switch` |\n| `sh codex.sh` | codex.plan.ai | |\n| `sh pi.sh` | 200:7ef6:…:fdd9 | home-pi, Yggdrasil IPv6; builds on `aarch64.plan.ai` |\n\n### Suggested batching\n\n1. `chronos.sh`, `logos.sh`, `atlas.sh`\n2. `aarch64.sh`, `omen.sh`, `peira.sh`\n3. `metis.sh`, `obsidian.sh`, `agency.sh`\n4. `relay.sh`, `peira-relay.sh`\n5. `charon.sh`, `uptime.sh`, `scanner.sh`\n6. `mmrcd.sh`, `cloud-images.sh`, `hippocampus.sh`\n7. `hugger.sh`, `hugger-amo.sh`, `hugger-hetzner.sh`\n8. `hyperion.sh`, `codex.sh`, `pi.sh`\n\nAlways include `relay.sh` and `peira-relay.sh` in the update workflow. Run them after the other batches unless the user explicitly asks to deploy a relay earlier or only deploy a relay. Treat relay deployment failures like any other deploy failure: inspect the first real Nix\u002Fbuild\u002FSSH error, apply the minimal fix, and re-run only the failed relay script after successful servers have already completed.\n\n`pi.sh` is the odd one out: it builds by delegating to `aarch64.plan.ai` (`--build-host`) and targets a Yggdrasil IPv6 address, so it needs both the builder and the Pi's mesh route to be up. Expect it to be the most fragile; treat failure like any other and report it.\n\n### Running deploys from an agent host (reagent)\n\nTwo traps will silently ruin a run here. Both are about how the deploy is *started*, not about the repo.\n\n1. **Launch detached, from a non-interactive shell.** Start each script as:\n\n   ```bash\n   setsid sh -c 'sh logos.sh > \u002Ftmp\u002Flogos.log 2>&1; echo EXIT=$? >> \u002Ftmp\u002Flogos.log' \u003C \u002Fdev\u002Fnull > \u002Fdev\u002Fnull 2>&1 &\n   ```\n\n   - Launching with a bare `&` from an *interactive* terminal gets the process batch-stopped (`Stopped(SIGTTOU)`, state `T`) and it hangs forever mid-`nix-copy-closure`. It looks exactly like a slow deploy. Check for it with `ps -o pid,stat,cmd` — a `T` state that never changes means it is stopped, not working. `kill -CONT` resumes it, but prefer starting correctly with `setsid`.\n   - Always capture to a log file and append `EXIT=$?`. Reading output back from a job handle is unreliable, and the exit code is the only trustworthy success signal.\n\n2. **Run nix commands with `devshell: false`.** reagent runs commands inside `nix develop`, and this flake has no `devShells.*.default`. `nix` then copies the flake *through git* (for the `private` submodule), which re-enters the devshell lookup and fails with:\n\n   ```\n   error: flake 'git+file:\u002F\u002F\u002F…\u002Fnixos-infra' does not provide attribute\n          'devShells.x86_64-linux.default' … or 'defaultPackage.x86_64-linux'\n   ```\n\n   This looks like a broken flake and is not — it is the outer devshell. Run deploys and `nix build`\u002F`nix flake` commands outside the devshell.\n\n### Preflight before the first batch\n\nDo these once, before launching anything; each one otherwise costs a full build cycle before failing:\n\n- **Check out the `private` submodule.** The host configs `import \"${self.private}\u002F\u003Chost>.nix\"` through git. If it is missing, every build dies with `path '…\u002Fprivate\u002Fchronos.nix' does not exist`:\n\n  ```bash\n  git submodule update --init --recursive\n  ```\n\n- **Seed `known_hosts` for every target**, or the deploy dies with `Host key verification failed` *after* a long build:\n\n  ```bash\n  for h in mmrcd.plan.ai cloud-images.plan.ai hippocampus.plan.ai codex.plan.ai hugger-hetzner.plan.ai; do\n    ssh-keyscan -T 10 -t ed25519,rsa \"$h\" >> ~\u002F.ssh\u002Fknown_hosts 2>\u002Fdev\u002Fnull\n  done\n  ```\n\n- **Probe reachability first.** `nc -w5 -z \u003Caddr> 22` (or a `ssh -o BatchMode=yes -o ConnectTimeout=8 root@\u003Chost> hostname`) saves a build on a host that is simply down. A host that is down is not a build failure — report it as an outage (see Step 3).\n\n- **Do not trust a first-attempt failure too quickly.** A single deploy attempt that fails with `Host key verification failed` or a transient `No route to host` is often just a missing known-host entry or a flaky route; fix that and re-run the affected script once before you start diagnosing Nix.\n\n### Building for aarch64 (`aarch64.sh` and `pi.sh`)\n\nDerivations for `aarch64-linux` cannot be built on an x86_64 host; they need a remote builder. `deploy\u002Fdefault.nix` registers `aarch64.plan.ai` as a `buildMachine`, but that only helps on that host. On the machine running this skill, supply the builder explicitly:\n\n```bash\n--builders 'ssh-ng:\u002F\u002Froot@aarch64.plan.ai aarch64-linux - 4 1 nixos-test,big-parallel'\n```\n\nIf you see hundreds of these, the builder was not used:\n\n```\nerror: Cannot build '\u002Fnix\u002Fstore\u002F…-foo.drv'.\n       Reason: platform mismatch\n       Required system: 'aarch64-linux'\n       Current system: 'x86_64-linux'\n```\n\n**`--builders` is a restricted setting.** The nix daemon honours it only from a *trusted* user, so as an untrusted user (reagent) you get:\n\n```\nwarning: ignoring the client-specified setting 'builders', because it is a restricted\nsetting and you are not a trusted user\n```\n\nand the builds fail as above. `--option system-features '… aarch64-linux'` and `NIX_CONFIG`\u002F`NIX_USER_CONF_FILES` are refused for the same reason (they are restricted settings *because* the user is untrusted — circular), and the untrusted daemon also rejects a local store with `Permission denied`. This is not a repo bug and cannot be fixed from inside the repo: it needs the agent host to add `reagent` (or whatever user runs this) to `nix.settings.trusted-users` or expose a privileged build path. Report it that way rather than inventing a workaround, and do not mark it fixed.\n\n## Step 3: Handle build failures\n\nIf any deploy fails:\n\n1. Read the build error output carefully.\n2. Identify the NixOS module, package, or flake input causing the failure. Look for lines like `error:`, `attribute ... not found`, `build of ... failed`, `while evaluating`, and the first project-owned source path in the trace.\n3. First fix issues owned by this repo. Check `modules\u002F`, `configuration.nix`, `flake.nix`, and server-specific directories such as `atlas\u002F`, `chronos\u002F`, `logos\u002F`, `pi\u002F`, and `omen\u002F`.\n4. If the failure is caused by an upstream flake input or tool repository that plan.ai controls, fix it in that tool repository instead of working around it here:\n   - Use `nix flake metadata --json` and `flake.lock` to identify the input name, locked rev, and repository URL.\n   - Locate an existing checkout if available, otherwise clone the upstream repository under a temporary working directory.\n   - Reproduce or inspect the failing derivation\u002Fsource in that repository, make the minimal fix, run the relevant formatter\u002Ftests\u002Fbuild checks, commit with a conventional commit message, and push the upstream fix.\n   - Return to `nixos-infra`, update only the affected flake input when possible (for example `nix flake lock --update-input \u003Cinput>`; use `nix flake update` only if targeted update is not possible), inspect and commit the resulting `flake.lock` change.\n   - Re-run only the affected server's deploy script.\n5. Re-run only failed server deploy scripts after fixes; do not re-run successful servers unnecessarily.\n6. If it fails again with a different Nix error, repeat the fix cycle up to 3 times per server, including upstream tool-repo fixes when that is the actual source of the failure.\n7. If a server still fails after 3 fix attempts, report the failure to the user with the last real error and the repository\u002Finput you traced it to.\n\n### Distinguish build failures from outages and environment problems\n\nNot every failed deploy is a build error, and treating a dead host like a broken package wastes a whole run. Classify the first real error before fixing anything:\n\n- **Outage — the host is unreachable.** Look for `No route to host`, `Connection timed out`, or SSH connect failures *after* a successful build. Do not touch the repo. Check whether the host is actually down (try the address directly, check the route), report it as an outage with the evidence, and move on to the remaining servers. Do not retry a dead host three times.\n  - A hostname resolving to a *server-local* address is a common cause: if `omen.plan.ai` resolves only to an address inside its own \u002F64, the route fails and `tracepath6` dies with `!H` at the last hop. That is a DNS\u002Faddress or host problem, not ours.\n  - A hostname resolving to a **Cloudflare** address (e.g. `2606:4700:…`) will never have port 22 open. Report it as a misconfigured record.\n- **Environment — our user lacks a privilege.** The `--builders` \u002F `trusted-users` case above. Not fixable in the repo; report the one-line change needed.\n- **Build failure — a derivation or evaluation error.** Only this goes through the 3-attempt fix cycle below: `error:`, `Cannot build …`, `attribute … not found`, `while evaluating`, `build of … failed`, followed by the first project-owned source path.\n\n### Fixing the actual fault, not the symptom\n\nWhen a service fails *after* a successful `switch` (the deploy script exits non-zero because a unit is unhealthy), the interesting error is in the switch output and in the journal on the target host:\n\n```bash\nssh root@\u003Chost> 'systemctl status \u003Cunit> --no-pager -l; journalctl -u \u003Cunit> -n 40 --no-pager'\n```\n\nA packaged binary that will not start is a packaging bug, not a NixOS config bug — fix it in the repository that owns the package, not by working around it here. For example, `status=127` with `error while loading shared libraries: libssl.so.3: cannot open shared object file` was `fixupPhase`'s `patchelf` emptying the binary's RPATH (`readelf -d \u003Cout>\u002Fbin\u002F\u003Cbin> | grep -i path` showing a blank runpath); the fix belonged in the upstream package's `.nix` (`dontPatchELF`\u002F`dontStrip` plus an explicit `postFixup` patchelf), followed by `nix flake lock --update-input \u003Cinput>` here.\n\n## Step 4: Commit fixes\n\nAfter all deploys complete, if any `.nix` files were modified to fix build errors, commit those changes with a descriptive conventional commit message:\n\n```bash\ngit add \u003Cchanged-files>\ngit commit -m 'fix: \u003Cwhat was fixed>'\n```\n\nIf fixes were applied for multiple servers, they can be combined into a single commit.\n\n## Step 5: Push commits\n\nAfter all deploys complete and any fix commits have been made, push all commits:\n\n```bash\ngit push\n```\n\n## Step 6: Summary\n\nReport:\n\n- whether anything was updated, and which inputs moved\n- a per-server deploy result — success, fixed-then-success, or still failing with the final real error\n- which servers deployed successfully\n- which servers failed and the final error, classified as a build failure vs. a host outage vs. an environment limitation\n- what fixes were applied, which files or upstream repositories they touched, and whether they were pushed\n- anything deliberately left alone for a human\n\n## Common Pitfalls\n\n1. Do not run more than 3 deploys in parallel.\n2. Do not use subagents for the deploy scripts.\n3. Do not push before all deploys and fix commits are complete.\n4. Re-run only failed deploys after fixes; do not re-run successful servers unnecessarily.\n5. Use conventional commit messages for all commits created during this workflow.\n6. `nixos-rebuild-ng` may try to stat `\u002Fetc\u002Fnixos\u002Fsystem.nix` even when `--flake` is passed. The deploy wrappers should set `NIX_PATH=nixos-system=\"$PWD\u002Fflake.nix\"` after `cd`-ing into the repo so deployments do not fail when `\u002Fetc\u002Fnixos` points into an unreadable `\u002Froot` directory.\n7. Deploy **every** script in the list above, every run. Do not narrow the fleet to the hosts that worked last time, and do not skip a host because it failed previously — try it again.\n8. Verify success from the exit code in the log and from the target host's health (`systemctl is-system-running`, `systemctl --failed`), not from the tail of the output. `nixos-rebuild` can print `Done.` and still exit non-zero when a unit failed to start.\n9. A deploy that appears to hang for tens of minutes is usually *stopped*, not slow: check `ps -o pid,stat,cmd` for state `T` (see the `setsid`\u002F`SIGTTOU` note above).\n10. Confirm the working tree at the end: `git status --short` clean, `git log --oneline origin\u002Ftrunk..HEAD` empty, no stray `nixos-rebuild` processes. Only `flake.lock` (and genuinely needed fixes) should differ from the starting commit.\n\n## Verification Checklist\n\n- [ ] `nix flake update` completed successfully\n- [ ] `flake.lock` update was committed with a conventional commit message\n- [ ] every deploy script in the table was run, in batches of at most 3\n- [ ] unreachable hosts were reported as outages, not retried as build failures\n- [ ] any failed deploys were diagnosed and retried after fixes\n- [ ] any fix changes were committed with conventional commit messages, upstream fixes pushed to their own repository first\n- [ ] deployed hosts were checked for health, not just for a zero exit\n- [ ] commits were pushed\n- [ ] final summary includes successes, failures, and fixes\n","# Update NixOS Infrastructure\n\n## Overview\n\nThis skill updates the nixos-infra flake inputs, deploys the resulting NixOS configurations to all servers, fixes build errors when possible, commits any fixes, and pushes the result.\n\nRun commands from the repository root.\n\n## When to Use\n\nUse this skill when the user asks to:\n\n- update NixOS\n- update or upgrade nixos-infra\n- update flake inputs\n- deploy the updated NixOS infrastructure\n- run the infra update workflow\n\nThis is also the skill behind the nightly, unattended update run. That run is\nexpected to be a quiet no-op on most days:\n\n- Check whether anything actually moved *before* rewriting `flake.lock`\n  (`nix flake update --dry-run`, or compare `nix flake metadata --json` input\n  revs against the locked revs).\n- If every input is already current, stop: report `nothing to update`. Do not\n  deploy, commit or push.\n- If inputs moved (or the dry run can't tell you, which is itself a reason to\n  look), continue with the full workflow below.\n\nRun fully autonomously when invoked as the nightly job — nobody is watching, so\ndo not ask for confirmation mid-run. Never leave production broken silently: if a\nserver is still failing after the 3 fix attempts, or you conclude you cannot fix\nit, message the person while the run is still going (server name, last real\nerror, the repo\u002Finput you traced it to) and then carry on with the remaining\nservers rather than aborting the run.\n\n## Step 1: Update flake inputs\n\nRun:\n\n```bash\nnix flake update\n```\n\nWait for it to complete. If it fails, diagnose the failure and report it to the user.\n\nAfter `nix flake update` succeeds, commit the updated `flake.lock` using the conventional commit message below:\n\n```bash\ngit add flake.lock\ngit commit -m 'chore: update flake inputs'\n```\n\n## Step 2: Deploy servers in batches of 3\n\nDeploy servers in batches of at most 3 in parallel. Within each batch, launch each deploy script directly as a background shell process from the repository root. Wait for every process in the batch to complete, then inspect all output before starting the next batch.\n\nDo not delegate deploys to subagents or external agent workers. Long-running deploy scripts can outlive delegated agent contexts; run the deploy scripts directly from the shell.\n\n### Every server gets deployed\n\n**Every deploy script in the repository root is part of this workflow.** Deploy the whole list below, every run — not just the ones named here, and not just the ones that succeeded last time. A host that was broken yesterday must be tried again today.\n\nThe full list is everything matching `*.sh` in the repository root that wraps `nixos-rebuild`, i.e. every script except `update.sh`, `reinstall-*.sh`, `sd-image.sh`, `incus-image.sh` and `export-incus.sh`. Before you start, take stock so the list can never silently shrink:\n\n```bash\nfor f in *.sh; do\n  case \"$f\" in reinstall-*|sd-image.sh|incus-image.sh|export-incus.sh|update.sh) continue;; esac\n  grep -l nixos-rebuild \"$f\"\ndone\n```\n\nCross-check that against the flake's `nixosConfigurations`:\n\n```bash\ngrep -E '^      [a-z0-9-]+ = nixpkgs' flake.nix\n```\n\nEvery configuration in the flake should either have a deploy script here or be a deliberate exception (currently `deploy`, which is the CI\u002Fdeploy-host configuration itself). If you add a server to the flake, add its deploy script here and add it to this list. If you find a deploy script not in this list, deploy it anyway and add it here.\n\n### Deploy scripts\n\n| Script | Target | Notes |\n|---|---|---|\n| `sh chronos.sh` | chronos.plan.ai | via port 22222 |\n| `sh logos.sh` | logos.plan.ai | |\n| `sh atlas.sh` | atlas.plan.ai | `boot`, not `switch` |\n| `sh aarch64.sh` | aarch64.plan.ai | needs a remote builder, see below |\n| `sh omen.sh` | omen.plan.ai | `exec sh odysseus.sh` |\n| `sh odysseus.sh` | omen.plan.ai | same host, config `odysseus`; `boot` |\n| `sh peira.sh` | peira.plan.ai | |\n| `sh metis.sh` | metis.plan.ai | |\n| `sh obsidian.sh` | obsidian.plan.ai | |\n| `sh agency.sh` | agency.plan.ai | |\n| `sh relay.sh` | relay.plan.ai | |\n| `sh peira-relay.sh` | relay.peira.plan.ai | |\n| `sh charon.sh` | 49.12.9.126 | plain IP, not a hostname |\n| `sh uptime.sh` | uptime.plan.ai | |\n| `sh scanner.sh` | 150.40.117.230 | plain IP; hosts the rustnmap API |\n| `sh mmrcd.sh` | mmrcd.plan.ai | |\n| `sh cloud-images.sh` | cloud-images.plan.ai | |\n| `sh hippocampus.sh` | hippocampus.plan.ai | |\n| `sh hugger.sh` | hugger-omen.plan.ai | lives on the omen box |\n| `sh hugger-amo.sh` | hugger-amo.plan.ai | |\n| `sh hugger-hetzner.sh` | hugger-hetzner.plan.ai | |\n| `sh hyperion.sh` | hyperion.plan.ai | `boot`, not `switch` |\n| `sh codex.sh` | codex.plan.ai | |\n| `sh pi.sh` | 200:7ef6:…:fdd9 | home-pi, Yggdrasil IPv6; builds on `aarch64.plan.ai` |\n\n### Suggested batching\n\n1. `chronos.sh`, `logos.sh`, `atlas.sh`\n2. `aarch64.sh`, `omen.sh`, `peira.sh`\n3. `metis.sh`, `obsidian.sh`, `agency.sh`\n4. `relay.sh`, `peira-relay.sh`\n5. `charon.sh`, `uptime.sh`, `scanner.sh`\n6. `mmrcd.sh`, `cloud-images.sh`, `hippocampus.sh`\n7. `hugger.sh`, `hugger-amo.sh`, `hugger-hetzner.sh`\n8. `hyperion.sh`, `codex.sh`, `pi.sh`\n\nAlways include `relay.sh` and `peira-relay.sh` in the update workflow. Run them after the other batches unless the user explicitly asks to deploy a relay earlier or only deploy a relay. Treat relay deployment failures like any other deploy failure: inspect the first real Nix\u002Fbuild\u002FSSH error, apply the minimal fix, and re-run only the failed relay script after successful servers have already completed.\n\n`pi.sh` is the odd one out: it builds by delegating to `aarch64.plan.ai` (`--build-host`) and targets a Yggdrasil IPv6 address, so it needs both the builder and the Pi's mesh route to be up. Expect it to be the most fragile; treat failure like any other and report it.\n\n### Running deploys from an agent host (reagent)\n\nTwo traps will silently ruin a run here. Both are about how the deploy is *started*, not about the repo.\n\n1. **Launch detached, from a non-interactive shell.** Start each script as:\n\n   ```bash\n   setsid sh -c 'sh logos.sh > \u002Ftmp\u002Flogos.log 2>&1; echo EXIT=$? >> \u002Ftmp\u002Flogos.log' \u003C \u002Fdev\u002Fnull > \u002Fdev\u002Fnull 2>&1 &\n   ```\n\n   - Launching with a bare `&` from an *interactive* terminal gets the process batch-stopped (`Stopped(SIGTTOU)`, state `T`) and it hangs forever mid-`nix-copy-closure`. It looks exactly like a slow deploy. Check for it with `ps -o pid,stat,cmd` — a `T` state that never changes means it is stopped, not working. `kill -CONT` resumes it, but prefer starting correctly with `setsid`.\n   - Always capture to a log file and append `EXIT=$?`. Reading output back from a job handle is unreliable, and the exit code is the only trustworthy success signal.\n\n2. **Run nix commands with `devshell: false`.** reagent runs commands inside `nix develop`, and this flake has no `devShells.*.default`. `nix` then copies the flake *through git* (for the `private` submodule), which re-enters the devshell lookup and fails with:\n\n   ```\n   error: flake 'git+file:\u002F\u002F\u002F…\u002Fnixos-infra' does not provide attribute\n          'devShells.x86_64-linux.default' … or 'defaultPackage.x86_64-linux'\n   ```\n\n   This looks like a broken flake and is not — it is the outer devshell. Run deploys and `nix build`\u002F`nix flake` commands outside the devshell.\n\n### Preflight before the first batch\n\nDo these once, before launching anything; each one otherwise costs a full build cycle before failing:\n\n- **Check out the `private` submodule.** The host configs `import \"${self.private}\u002F\u003Chost>.nix\"` through git. If it is missing, every build dies with `path '…\u002Fprivate\u002Fchronos.nix' does not exist`:\n\n  ```bash\n  git submodule update --init --recursive\n  ```\n\n- **Seed `known_hosts` for every target**, or the deploy dies with `Host key verification failed` *after* a long build:\n\n  ```bash\n  for h in mmrcd.plan.ai cloud-images.plan.ai hippocampus.plan.ai codex.plan.ai hugger-hetzner.plan.ai; do\n    ssh-keyscan -T 10 -t ed25519,rsa \"$h\" >> ~\u002F.ssh\u002Fknown_hosts 2>\u002Fdev\u002Fnull\n  done\n  ```\n\n- **Probe reachability first.** `nc -w5 -z \u003Caddr> 22` (or a `ssh -o BatchMode=yes -o ConnectTimeout=8 root@\u003Chost> hostname`) saves a build on a host that is simply down. A host that is down is not a build failure — report it as an outage (see Step 3).\n\n- **Do not trust a first-attempt failure too quickly.** A single deploy attempt that fails with `Host key verification failed` or a transient `No route to host` is often just a missing known-host entry or a flaky route; fix that and re-run the affected script once before you start diagnosing Nix.\n\n### Building for aarch64 (`aarch64.sh` and `pi.sh`)\n\nDerivations for `aarch64-linux` cannot be built on an x86_64 host; they need a remote builder. `deploy\u002Fdefault.nix` registers `aarch64.plan.ai` as a `buildMachine`, but that only helps on that host. On the machine running this skill, supply the builder explicitly:\n\n```bash\n--builders 'ssh-ng:\u002F\u002Froot@aarch64.plan.ai aarch64-linux - 4 1 nixos-test,big-parallel'\n```\n\nIf you see hundreds of these, the builder was not used:\n\n```\nerror: Cannot build '\u002Fnix\u002Fstore\u002F…-foo.drv'.\n       Reason: platform mismatch\n       Required system: 'aarch64-linux'\n       Current system: 'x86_64-linux'\n```\n\n**`--builders` is a restricted setting.** The nix daemon honours it only from a *trusted* user, so as an untrusted user (reagent) you get:\n\n```\nwarning: ignoring the client-specified setting 'builders', because it is a restricted\nsetting and you are not a trusted user\n```\n\nand the builds fail as above. `--option system-features '… aarch64-linux'` and `NIX_CONFIG`\u002F`NIX_USER_CONF_FILES` are refused for the same reason (they are restricted settings *because* the user is untrusted — circular), and the untrusted daemon also rejects a local store with `Permission denied`. This is not a repo bug and cannot be fixed from inside the repo: it needs the agent host to add `reagent` (or whatever user runs this) to `nix.settings.trusted-users` or expose a privileged build path. Report it that way rather than inventing a workaround, and do not mark it fixed.\n\n## Step 3: Handle build failures\n\nIf any deploy fails:\n\n1. Read the build error output carefully.\n2. Identify the NixOS module, package, or flake input causing the failure. Look for lines like `error:`, `attribute ... not found`, `build of ... failed`, `while evaluating`, and the first project-owned source path in the trace.\n3. First fix issues owned by this repo. Check `modules\u002F`, `configuration.nix`, `flake.nix`, and server-specific directories such as `atlas\u002F`, `chronos\u002F`, `logos\u002F`, `pi\u002F`, and `omen\u002F`.\n4. If the failure is caused by an upstream flake input or tool repository that plan.ai controls, fix it in that tool repository instead of working around it here:\n   - Use `nix flake metadata --json` and `flake.lock` to identify the input name, locked rev, and repository URL.\n   - Locate an existing checkout if available, otherwise clone the upstream repository under a temporary working directory.\n   - Reproduce or inspect the failing derivation\u002Fsource in that repository, make the minimal fix, run the relevant formatter\u002Ftests\u002Fbuild checks, commit with a conventional commit message, and push the upstream fix.\n   - Return to `nixos-infra`, update only the affected flake input when possible (for example `nix flake lock --update-input \u003Cinput>`; use `nix flake update` only if targeted update is not possible), inspect and commit the resulting `flake.lock` change.\n   - Re-run only the affected server's deploy script.\n5. Re-run only failed server deploy scripts after fixes; do not re-run successful servers unnecessarily.\n6. If it fails again with a different Nix error, repeat the fix cycle up to 3 times per server, including upstream tool-repo fixes when that is the actual source of the failure.\n7. If a server still fails after 3 fix attempts, report the failure to the user with the last real error and the repository\u002Finput you traced it to.\n\n### Distinguish build failures from outages and environment problems\n\nNot every failed deploy is a build error, and treating a dead host like a broken package wastes a whole run. Classify the first real error before fixing anything:\n\n- **Outage — the host is unreachable.** Look for `No route to host`, `Connection timed out`, or SSH connect failures *after* a successful build. Do not touch the repo. Check whether the host is actually down (try the address directly, check the route), report it as an outage with the evidence, and move on to the remaining servers. Do not retry a dead host three times.\n  - A hostname resolving to a *server-local* address is a common cause: if `omen.plan.ai` resolves only to an address inside its own \u002F64, the route fails and `tracepath6` dies with `!H` at the last hop. That is a DNS\u002Faddress or host problem, not ours.\n  - A hostname resolving to a **Cloudflare** address (e.g. `2606:4700:…`) will never have port 22 open. Report it as a misconfigured record.\n- **Environment — our user lacks a privilege.** The `--builders` \u002F `trusted-users` case above. Not fixable in the repo; report the one-line change needed.\n- **Build failure — a derivation or evaluation error.** Only this goes through the 3-attempt fix cycle below: `error:`, `Cannot build …`, `attribute … not found`, `while evaluating`, `build of … failed`, followed by the first project-owned source path.\n\n### Fixing the actual fault, not the symptom\n\nWhen a service fails *after* a successful `switch` (the deploy script exits non-zero because a unit is unhealthy), the interesting error is in the switch output and in the journal on the target host:\n\n```bash\nssh root@\u003Chost> 'systemctl status \u003Cunit> --no-pager -l; journalctl -u \u003Cunit> -n 40 --no-pager'\n```\n\nA packaged binary that will not start is a packaging bug, not a NixOS config bug — fix it in the repository that owns the package, not by working around it here. For example, `status=127` with `error while loading shared libraries: libssl.so.3: cannot open shared object file` was `fixupPhase`'s `patchelf` emptying the binary's RPATH (`readelf -d \u003Cout>\u002Fbin\u002F\u003Cbin> | grep -i path` showing a blank runpath); the fix belonged in the upstream package's `.nix` (`dontPatchELF`\u002F`dontStrip` plus an explicit `postFixup` patchelf), followed by `nix flake lock --update-input \u003Cinput>` here.\n\n## Step 4: Commit fixes\n\nAfter all deploys complete, if any `.nix` files were modified to fix build errors, commit those changes with a descriptive conventional commit message:\n\n```bash\ngit add \u003Cchanged-files>\ngit commit -m 'fix: \u003Cwhat was fixed>'\n```\n\nIf fixes were applied for multiple servers, they can be combined into a single commit.\n\n## Step 5: Push commits\n\nAfter all deploys complete and any fix commits have been made, push all commits:\n\n```bash\ngit push\n```\n\n## Step 6: Summary\n\nReport:\n\n- whether anything was updated, and which inputs moved\n- a per-server deploy result — success, fixed-then-success, or still failing with the final real error\n- which servers deployed successfully\n- which servers failed and the final error, classified as a build failure vs. a host outage vs. an environment limitation\n- what fixes were applied, which files or upstream repositories they touched, and whether they were pushed\n- anything deliberately left alone for a human\n\n## Common Pitfalls\n\n1. Do not run more than 3 deploys in parallel.\n2. Do not use subagents for the deploy scripts.\n3. Do not push before all deploys and fix commits are complete.\n4. Re-run only failed deploys after fixes; do not re-run successful servers unnecessarily.\n5. Use conventional commit messages for all commits created during this workflow.\n6. `nixos-rebuild-ng` may try to stat `\u002Fetc\u002Fnixos\u002Fsystem.nix` even when `--flake` is passed. The deploy wrappers should set `NIX_PATH=nixos-system=\"$PWD\u002Fflake.nix\"` after `cd`-ing into the repo so deployments do not fail when `\u002Fetc\u002Fnixos` points into an unreadable `\u002Froot` directory.\n7. Deploy **every** script in the list above, every run. Do not narrow the fleet to the hosts that worked last time, and do not skip a host because it failed previously — try it again.\n8. Verify success from the exit code in the log and from the target host's health (`systemctl is-system-running`, `systemctl --failed`), not from the tail of the output. `nixos-rebuild` can print `Done.` and still exit non-zero when a unit failed to start.\n9. A deploy that appears to hang for tens of minutes is usually *stopped*, not slow: check `ps -o pid,stat,cmd` for state `T` (see the `setsid`\u002F`SIGTTOU` note above).\n10. Confirm the working tree at the end: `git status --short` clean, `git log --oneline origin\u002Ftrunk..HEAD` empty, no stray `nixos-rebuild` processes. Only `flake.lock` (and genuinely needed fixes) should differ from the starting commit.\n\n## Verification Checklist\n\n- [ ] `nix flake update` completed successfully\n- [ ] `flake.lock` update was committed with a conventional commit message\n- [ ] every deploy script in the table was run, in batches of at most 3\n- [ ] unreachable hosts were reported as outages, not retried as build failures\n- [ ] any failed deploys were diagnosed and retried after fixes\n- [ ] any fix changes were committed with conventional commit messages, upstream fixes pushed to their own repository first\n- [ ] deployed hosts were checked for health, not just for a zero exit\n- [ ] commits were pushed\n- [ ] final summary includes successes, failures, and fixes\n",{"name":5,"author":24,"license":15,"version":25,"metadata":26,"description":7,"user_invocable":34},"plan.ai","1.1.0",{"hermes":27},{"tags":28,"related_skills":33},[29,30,31,32],"nixos","infrastructure","deploy","flake-update",[],true,"trunk","ae6b6d8ae743bf5a1af509d00f07168869ab26b3",".claude\u002Fskills\u002Fupdate-nixos",0,"https:\u002F\u002Fgithub.com\u002Fplanailabs\u002Fnixos-infra","https:\u002F\u002Fgithub.com\u002Fplanailabs","https:\u002F\u002Fplan.ai","2026-11-13 18:32:11",{"source":8,"skillName":5,"commands":44,"prompt":54,"zipAvailable":34},[45,48,51],{"tool":46,"command":47},"npx","npx skills add planailabs\u002Fnixos-infra --skill update-nixos",{"tool":49,"command":50},"bunx","bunx skills add planailabs\u002Fnixos-infra --skill update-nixos",{"tool":52,"command":53},"pnpm","pnpm dlx skills add planailabs\u002Fnixos-infra --skill update-nixos","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fplanailabs\u002Fnixos-infra\u002Fblob\u002Ftrunk\u002F.claude\u002Fskills\u002Fupdate-nixos\u002FSKILL.md",[],[57,64,69,76],{"skillNo":58,"name":59,"nameZh":6,"description":60,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":61,"categories":62,"keywords":63,"publishedAt":19},"01M784SR5XNTH2VERG3XDJENK2","fix-codex-litellm","Use when the codex.plan.ai litellm plugin (Codex OAuth custom provider) is throwing errors — HTTP 400\u002F4xx\u002F5xx from the Codex \u002Fresponses endpoint, request\u002Fresponse translation failures, model-name or auth errors — to diagnose, fix the provider fork, and redeploy codex.plan.ai.","https:\u002F\u002Fgithub.com\u002Fplanailabs\u002Fnixos-infra\u002Fblob\u002Ftrunk\u002F.hermes\u002Fskills\u002Ffix-codex-litellm\u002FSKILL.md",[],[],{"skillNo":65,"name":59,"nameZh":6,"description":60,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":66,"categories":67,"keywords":68,"publishedAt":19},"01M784SDEW9G4REFT90HT4EDM2","https:\u002F\u002Fgithub.com\u002Fplanailabs\u002Fnixos-infra\u002Fblob\u002Ftrunk\u002F.claude\u002Fskills\u002Ffix-codex-litellm\u002FSKILL.md",[],[],{"skillNo":70,"name":71,"nameZh":6,"description":72,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":19},"01M784S8HE4XHFBK0MFZ4VTFX6","zitadel-bootstrap","Use when setting up Zitadel for a new plan.ai-style deployment (a cloud console, a chat\u002Fagent and optionally a Harbor on their own domains, like webapp.agency) or re-running it — asks for the domains, org and login names, social-login credentials and shared keys, writes ansible\u002Fzitadel\u002Fdeployments\u002F\u003Cname>.yml, runs setup.yml (Zitadel orgs, login policy, IdPs, projects, clients, service users) and secrets.yml (the rest of the secrets, private\u002F\u003Cname>-{cloud,chat,harbor}.nix).","https:\u002F\u002Fgithub.com\u002Fplanailabs\u002Fnixos-infra\u002Fblob\u002Ftrunk\u002F.agents\u002Fskills\u002Fzitadel-bootstrap\u002FSKILL.md",[],[],{"skillNo":77,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":19},"01M784S448ZG86SRRW2RQJH65N","codex-healthcheck","Use when checking whether the codex.plan.ai litellm proxy works (scheduled health check) or when it is reported broken — probe \u002Fv1\u002Fmodels + a tiny chat completion, classify the failure against the known layers, then fix it (container\u002Fconfig, fork+repin+deploy, auth) and verify.","https:\u002F\u002Fgithub.com\u002Fplanailabs\u002Fnixos-infra\u002Fblob\u002Ftrunk\u002F.agents\u002Fskills\u002Fcodex-healthcheck\u002FSKILL.md",[],[]]