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" {