deploy: automate a full local reinstall, self-elevating and interactive-safe

./scripts/deploy install <config> localhost now branches on is_live_installer()
(checks uname -n): outside a live installer it builds installer-iso, stages
its kernel/initrd on the ESP and the iso file on a disk the caller picks
(never auto-picked — the wrong disk here is destroyed mid-install), writes a
systemd-boot one-shot findiso= entry with homelab.install=<config> on the
kernel cmdline, and does a real systemctl reboot (not kexec — terra's
kexec-local hang is specifically in kexec's device-shutdown pass, a real ACPI
reboot never runs that code at all).

installer-iso gains homelab-auto-install.service: once homelab-checkout.service
clones the repo, it reads homelab.install= back off /proc/cmdline and re-runs
the identical deploy command itself, now genuinely inside the installer, so
it takes the disko+nixos-install branch instead of preparing again. The whole
reinstall is one command and unattended after the first reboot.

Also: every root-requiring path (kexec-local, the new prepare-and-reboot
branch, the disko+nixos-install branch) self-elevates via a require_root()
helper that re-execs the original invocation under sudo -E, instead of dying
and asking the caller to prefix sudo themselves. Uses an absolute script path
captured before the script's own cd, so the re-exec is correct regardless of
how it was invoked.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-24 01:53:45 +02:00
co-authored by Claude Sonnet 5
parent fd8328d7b3
commit 0ea90200b4
4 changed files with 222 additions and 42 deletions
+16 -1
View File
@@ -114,7 +114,22 @@ kept its ssh host key. Run it after ANY change to the kexec paths.
cycle, not a slow jump. Near-certainly amdgpu (RX 6800 XT): discrete AMD GPUs are known
to hang during kexec's device-shutdown pass with no clean handoff before the jump —
same class of issue as jupiter's `reboot=pci` workaround, just fatal here instead of
slow. Use the USB installer path instead (README's "First install on terra" section).
slow. Use `./scripts/deploy install terra localhost` instead (README's "First install
on terra" section) — it detects it isn't inside a live installer yet and reboots via
a real `systemctl reboot` + systemd-boot one-shot `findiso=` entry, not kexec.
- **`./scripts/deploy install <config> localhost`'s behavior depends on `uname -n`**
(`is_live_installer()`): on a real running OS it builds `installer-iso`, stages it
locally, and reboots into it (`local_install_prepare_and_reboot()`); only inside
`nixos-installer` (kexec) or `homelab-installer` (installer-iso) does it actually run
disko + `nixos-install`. `installer-iso`'s `homelab-auto-install.service` closes the
loop: it reads `homelab.install=<config>` back off `/proc/cmdline` (set by the prepare
step) and re-runs the identical command itself once `homelab-checkout.service` has
cloned the repo — the whole reinstall is one command and unattended after the first
reboot. It always ASKS where to stage the iso file (never auto-picks — the wrong disk
here is destroyed mid-install) and refuses if that turns out to be the disk
`disk-config.nix` is about to wipe; `HOMELAB_INSTALLER_STAGE_DIR` skips the prompt for
scripted use. Both this and `kexec-local` self-elevate via `sudo` (`require_root()`)
rather than requiring you to prefix the command yourself.
- **disko wipes only the OS disk** named in `hosts/<h>/disk-config.nix`; data disks are
plain `fileSystems` in `configuration.nix`.
- `nixos-anywhere`/kexec needs a writable root; **ZimaOS root is read-only**, hence the