Files
2026-10-26 16:18:48 -04:00

68 lines
22 KiB
Markdown

# bin/
The `skyg` CLI — the single entry point for all system management tasks in this repo.
## Structure
```
bin/
├── skyg # Bash shim: exec nu --commands "use lib/cmds.nu *; skyg $*"
├── temp-monitor # NuShell script: collect CPU/GPU temps to CSV + optional graph
├── TEMP_MONITOR_README.md # Usage docs for temp-monitor
└── lib/
├── cmds.nu # Dispatcher + bare `skyg` + `skyg profiles`
├── os.nu # `skyg os` (local NixOS rebuild/switch/rollback)
├── remote.nu # `skyg remote *` (deploy, install, boot-all, status, reboot-pending)
├── secrets.nu # `skyg secrets [list]/show/edit/compare`
├── ca.nu # `skyg ca init/issue`
├── buzz.nu # `skyg buzz identity`
├── pkgs.nu # `skyg pkgs update`
├── flake.nu # `skyg flake update/check/check-versions`
├── build.nu # `skyg build image/openwrt`
├── render.nu # `skyg render html-tpl`
├── hm.nu # `skyg hm <action>`
├── net.nu # `skyg net check` (per-device NIC info + shared-server speed test), `skyg net last`
├── net-nic.sh # Bash probe piped to each device by `skyg net check` (NIC model, driver, link/supported speeds)
├── helpers.nu # Shared helpers: REPO_ROOT const + internal functions
├── profile.nu # Profile helpers and tab-completion data
├── types.nu # Tab-completion completer functions
└── remote.utils.nu # Remote-specific helpers (boot info, wait-for-host, notify)
```
## Key Commands
| Command | Description |
| ------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `skyg os switch` | Rebuild and switch local system |
| `skyg os rollback` | Roll back to previous generation |
| `skyg remote switch <host>` | Deploy to a remote host |
| `skyg remote install <host>` | Fresh-install a remote host via nixos-anywhere, using `hosts/<profile>.disko.nix`. Always wipes the disks in that file. Aborts if the file is missing, if the host already boots NixOS from disk (unless `--force-wipe`), or if you do not type the short hostname. |
| `skyg remote status <host>` | Check status of a single remote host: booted / current / next-boot generation. `reboot_pending` = booted != next boot (`/nix/var/nix/profiles/system`), `needs_build` = local build != next boot (or `"unknown"` if the local eval fails). So hosts deployed with `boot` show up correctly. |
| `skyg remote status --all` | Check status of all remote hosts |
| `skyg remote boot-all` | Boot all remote hosts |
| `skyg remote reboot-pending` | Reboot every remote host with a pending reboot (`booted-system` != next-boot generation, so `boot` deploys count). Lists them, asks for confirmation, then reboots one at a time. Each host must prove it rebooted (boot id changed) and come back on its next-boot generation, otherwise it is reported as failed. Sends a desktop notification per host. |
| `skyg hm switch` | Apply Home Manager config |
| `skyg flake update [input]` | Update flake inputs |
| `skyg flake check` | Run `nix flake check --no-build` |
| `skyg flake check-versions` | Verify NixOS release version consistency in flake.nix |
| `skyg build image iso\|pi1\|pi2` | Build bootable image — ISO (`iso`) or Pi SD card image (`pi1`, `pi2`) |
| `skyg build openwrt [router]` | Deploy OpenWrt config |
| `skyg profiles` | List valid local/remote profiles |
| `skyg secrets list` | List known secret names |
| `skyg secrets show <secret>` | Decrypt a secret to `.tmp/unencrypted-<secret>` |
| `skyg secrets edit <secret> [--yaml]` | Encrypt a working copy back into the secret |
| `skyg secrets compare <secret>` | Diff the working copy against the stored secret |
| `skyg ca init` | Generate the lab root CA: key → `secrets/lab-ca-key.age`, cert → `configs/pki/lab-ca.crt` (see `configs/pki/ABOUTME.md`) |
| `skyg ca issue <domain> --for <host>` | Mint a TLS leaf cert signed by the lab CA: cert → `configs/pki/<domain>.crt`, key → `secrets/<name>-tls-key.age`. Auto-registers missing `secrets.nix` entries. |
| `skyg buzz identity <robot>` | Make a Buzz (Nostr) identity for a robot's Hermes agent and merge `BUZZ_RELAY_URL` / `BUZZ_PRIVATE_KEY` (plus optional `--channels`, `--home-channel`). The bot answers anyone on the relay by default (`BUZZ_ALLOW_ALL_USERS=true`); `--allowed-users <npubs>` limits it to a list, `--restricted` allows no one into `secrets/robots-<robot>.age`, keeping its other lines. Refuses to replace an existing key without `--rotate`. `--dry-run` only shows the npub. Prints the `buzz-manage add-member <npub>` step. Needs `nak` (dev shell). |
| `skyg pkgs update [--all\|<pkg>]` | Update one or all custom packages |
| `skyg net check [device]` | For every managed device (or just `[device]`): report the NIC on the default route (model, driver, current link speed, supported speeds), then run `speedtest-go` via `nix-shell` against one shared server. Logs progress per device and returns a table. `--server <id>` picks the server; `--no-speedtest` skips the test. Offline devices are listed, not tested. Every run saves the table to `.tmp/net-checks/<timestamp>.nuon`; `--save <file>` also writes it to `<file>` (format from extension). The server is saved in `.tmp/net-checks/server.nuon` on first run; later runs ask whether to change it (fuzzy pick list from `speedtest-go --list`). `--server` skips the question and leaves the saved server alone. |
| `skyg net last` | Show the table from the most recent `skyg net check` run (newest file in `.tmp/net-checks/`). |
| `skyg render html-tpl <file>` | Render a Gitea `.tmpl` and serve it on `127.0.0.1` for preview. Foreground — Ctrl+C to stop. `<file>` tab-completes from `**/*.tmpl`. |
## Agent Note
> **Never invoke `skyg` commands that trigger builds or switches.**
> Only the user runs these. Edits to `cmds.nu` / `remote.nu` are safe if the user asks for CLI changes.