devshell: Add container support to ssh-machine
Update docs / update (push) Canceled after 0s
CI / Check, build and cache nixfiles (push) Canceled after 25m22s

Port `ssh-machine` to Python and derive container targets from their
hosting boxes. Configure `tower` to prefer its home DNS name and fall
back to its Tailscale name.
This commit is contained in:
jackos1998 committed 2026-11-22 23:26:00 +00:00
1 parent 19265dfc75
commit a75d94f492
9 files changed
+220 -91

No files matched your search

+14 -5
View File
@@ -57,10 +57,19 @@ Generated profiles deploy in this order:
#### `ssh-machine`
`ssh-machine <name> [cmd]` resolves `user@host` and the merged global/node `sshOpts` from
`.#deploy`, using the same `my.deploy.enable` gate and `@` → `-at-` mangling as `deploy`, then runs
`ssh`. Connection settings for all nodes are cached together in `.cache/ssh-machine/`;
normal connections read the cache without running Nix. A fingerprint of the checkout
`ssh-machine <name> [cmd]` connects using the deploy-rs node's SSH user and merged global and
node `sshOpts`. Box and home targets use the same `my.deploy.enable` gate and `@` → `-at-`
mangling as `deploy`. If a box sets `my.deploy.sshHostnames`, the command checks the
addresses in order for a reachable SSH port and uses the last address if the earlier checks fail.
For NixOS containers, use `ssh-machine middleman` or `ssh-machine shill.container-middleman`.
The qualified name selects the host when multiple containers share a name or a deploy node has
the same name. The command connects to the host's deploy node and uses `systemd-run` to open a
root Bash shell in the container or run the supplied command there. Stdin and the command's
exit status are available to the caller.
Connection settings and container names are cached together in `.cache/ssh-machine/`.
Normal connections read the cache without running Nix. A fingerprint of the checkout
automatically invalidates it. In a Jujutsu workspace (including secondary workspaces without a
Git checkout) it is the working-copy commit ID, so any snapshotted change counts, including new
files that are not ignored. In a Git-only checkout it is HEAD plus staged/unstaged tracked
@@ -102,7 +111,7 @@ command with no arguments for its help. From
| `home-switch [args]` | `home-manager switch --flake .`. |
| `deploy [args]` | `deploy-rs --skip-checks` (wrapper package in `devshell/default.nix`). |
| `deploy --targets .#<node1> .#<node2>` | Deploys several nodes in one invocation. |
| `ssh-machine <name> [cmd]` | SSH to a system or home by name, resolving target/options from its deploy-rs node (see above). |
| `ssh-machine <name> [cmd]` | Connect to a box, home-manager config or NixOS container using deploy-rs SSH settings. |
| `run-vm <host>` | Boots a system as a dev VM: installs `.keys/dev.key` into a temp `xchg/`, then `nix run`s `config.my.buildAs.devVM`. |
| `build-iso <host>` | Builds `config.my.buildAs.iso`. |
| `build-kexec <host>` | Builds `config.my.buildAs.kexecTree`. |
+2
View File
@@ -42,6 +42,8 @@ over Tailscale.
- NetworkManager (`wpa_supplicant` backend) with `systemd-resolved`; networkd `wait-online`
is disabled. The Wi-Fi interface is renamed to `wifi` by MAC.
- `ssh-machine tower` uses `tower.dyn.h.nul.ie` when its SSH port is reachable and
`tower.ts.nul.ie` over Tailscale otherwise.
- Steam and Wireshark enabled; `fstrim`, LVM thin provisioning.
- `nix.gc.automatic = false` — GC is run manually on the laptop.