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 <noreply@anthropic.com>
This commit is contained in:
1 parent
ff752cb803
commit
3c491b1624
2 files changed
+22
No files matched your search
@@ -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
|
back with its identity, memories, workspace and NixOS config intact. That is
|
||||||
the intended repair, not a last resort.
|
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
|
## Nix flavour
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ def main [] {
|
|||||||
# from any directory - no local checkout of this repo needed.
|
# from any directory - no local checkout of this repo needed.
|
||||||
def "main setup" [
|
def "main setup" [
|
||||||
--flake: string = "git+ssh://gitea@minipc1.lab.internal:22/ari/hermenix.git"
|
--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")
|
$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"
|
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 parent = ($base | path dirname)
|
||||||
let fstype = ((do -i { ^stat -f -c "%T" $parent } | complete).stdout | str trim)
|
let fstype = ((do -i { ^stat -f -c "%T" $parent } | complete).stdout | str trim)
|
||||||
let use_btrfs = if $fstype != "btrfs" {
|
let use_btrfs = if $fstype != "btrfs" {
|
||||||
|
|||||||
Reference in new issue
Block a user