diff --git a/modules/host.nix b/modules/host.nix index a747ed2..7843e6a 100644 --- a/modules/host.nix +++ b/modules/host.nix @@ -806,12 +806,6 @@ in }; }; - # ===================================================================== - # Host GC is now safe: the guest has its own store and shares nothing. - # ===================================================================== - nix.gc.automatic = lib.mkDefault true; - nix.gc.options = lib.mkDefault "--delete-older-than 30d"; - environment.systemPackages = [ (pkgs.writeShellScriptBin "hermes-vm" '' set -euo pipefail diff --git a/nu/hermenix.nu b/nu/hermenix.nu index 49ed5c2..b34a2ca 100644 --- a/nu/hermenix.nu +++ b/nu/hermenix.nu @@ -51,6 +51,19 @@ def shquote [s: string] { "'" + ($s | str replace --all "'" "'\\''") + "'" } +# `truncate -s` treats a bare number as bytes, not gigabytes - the size +# prompts' own defaults ("80G", "20G") make gigabytes the obvious intent, so +# normalize a bare integer answer to that rather than silently creating a +# byte-sized disk. Anything with an existing suffix passes through as-is. +def normalize-size [s: string] { + try { + let n = ($s | into int) + $"($n)G" + } catch { + $s + } +} + # Run a command, sudo-prefixed unless already root (set once via # $env.HERMENIX_NEED_SUDO at the top of `main setup`). Fails loudly, like any # other external command, if the command fails. @@ -149,9 +162,11 @@ def "main setup" [ priv btrfs subvolume create $path | ignore priv chattr +C $path do -i { priv btrfs property set $path compression none } | complete | ignore + priv chown "hermes-vm:hermes-vm" $path ok $"subvolume ($path) \(nodatacow\)" } else { priv mkdir "-p" $path + priv chown "hermes-vm:hermes-vm" $path } } make-subvol $"($base)/system" $use_btrfs @@ -164,10 +179,12 @@ def "main setup" [ let system_existed = ((priv-out test "-f" $system_img).exit_code == 0) if $system_existed { let sz = ((priv-out du "-h" "--apparent-size" $system_img).stdout | str trim | split column "\t" | get column0.0) + priv chown "hermes-vm:hermes-vm" $system_img ok $"system disk exists \(($sz)\)" } else { - let syssize = ask "System disk size" "80G" + let syssize = (normalize-size (ask "System disk size" "80G")) priv truncate "-s" $syssize $system_img + priv chown "hermes-vm:hermes-vm" $system_img if $use_btrfs { let attrs = (priv-out lsattr "-l" $system_img).stdout if ($attrs | str contains "No_COW") { @@ -182,11 +199,13 @@ def "main setup" [ if (priv-out test "-f" $state_img).exit_code == 0 { let sz = ((priv-out du "-h" "--apparent-size" $state_img).stdout | str trim | split column "\t" | get column0.0) + priv chown "hermes-vm:hermes-vm" $state_img ok $"state disk exists \(($sz)\)" } else { - let statesize = ask "State disk size" "20G" + let statesize = (normalize-size (ask "State disk size" "20G")) priv truncate "-s" $statesize $state_img priv mkfs.ext4 "-q" "-L" hermes-state $state_img + priv chown "hermes-vm:hermes-vm" $state_img ok "state disk created and formatted (label: hermes-state)" }