From 3c491b1624cb22be59e4ec8254fbb47b5efb9a7d Mon Sep 17 00:00:00 2001 From: Ari Sosnovsky Date: Wed, 16 Sep 2026 10:42:41 -0400 Subject: [PATCH] Add hermenix setup --clean for a fully fresh start Encodes the "start over" runbook from tonight's incident as a flag: stops hermes-vm.service, deletes system.raw/state.raw/OVMF_VARS.fd, then continues through the normal setup flow. Leaves the btrfs subvolumes and any snapshots untouched - only the files inside them. Gated behind a confirm-word ("clean") since it's destructive. Verified in a sandbox: confirms it stops the VM and removes exactly the three targeted files (nothing else), that declining the confirm-word aborts without touching anything, and that it correctly falls through into the normal disk-creation flow afterward. Co-Authored-By: Claude Sonnet 5 --- README.md | 9 +++++++++ nu/hermenix.nu | 13 +++++++++++++ 2 files changed, 22 insertions(+) diff --git a/README.md b/README.md index e05cd21..c467eb8 100644 --- a/README.md +++ b/README.md @@ -636,6 +636,15 @@ fresh image to the system disk, and leave the state disk alone — Hermes comes back with its identity, memories, workspace and NixOS config intact. That is the intended repair, not a last resort. +### Starting completely fresh + +`hermenix setup --clean` stops the VM and deletes the existing +`system.raw`/`state.raw`/UEFI vars before walking through setup again — for +when you want a genuinely clean first boot rather than the disk-exists, +skip-ahead path. It leaves the btrfs subvolumes and any snapshots alone +(only the files inside them), and asks you to type `clean` to confirm before +touching anything. + --- ## Nix flavour diff --git a/nu/hermenix.nu b/nu/hermenix.nu index b34a2ca..b113d31 100644 --- a/nu/hermenix.nu +++ b/nu/hermenix.nu @@ -98,6 +98,7 @@ def main [] { # from any directory - no local checkout of this repo needed. def "main setup" [ --flake: string = "git+ssh://gitea@minipc1.lab.internal:22/ari/hermenix.git" + --clean # stop the VM and delete existing disk images + UEFI vars first, for a fully fresh start ] { $env.HERMENIX_NEED_SUDO = ((^id -u | str trim) != "0") @@ -142,6 +143,18 @@ def "main setup" [ let base = ask "Directory for the disk images" "/var/lib/hermes-vm" + if $clean { + warn "--clean: this stops the VM and deletes the existing system/state" + warn "disk images and UEFI vars under this directory. The btrfs" + warn "subvolumes and any snapshots are left alone." + if not (confirm-word "clean" "Type 'clean' to confirm:") { die "aborted" } + do -i { priv systemctl stop hermes-vm.service } | complete | ignore + do -i { priv rm "-f" $"($base)/system/system.raw" } | complete | ignore + do -i { priv rm "-f" $"($base)/state/state.raw" } | complete | ignore + do -i { priv rm "-f" $"($base)/OVMF_VARS.fd" } | complete | ignore + ok "cleaned existing disk images" + } + let parent = ($base | path dirname) let fstype = ((do -i { ^stat -f -c "%T" $parent } | complete).stdout | str trim) let use_btrfs = if $fstype != "btrfs" {