chore: global fixups ahead of the next microvm guest - #119
Merged
Conversation
The user and its authorized keys were defined in the common host baseline, which also pulls in sops, the substituter list and a node exporter. MicroVM guests want the user without any of that, so it moves to a module both can import. Host-specific groups stay in the baseline and merge on top.
NixOS modules put their state under /var/lib, so any guest running an ordinary service writes there whether or not it was planned for. Guest volumes are sparse, so the larger size costs nothing until it is used, and microvm only creates them when missing — a guest that boots with a small /var/lib cannot be grown from Nix afterwards. Genuinely bulky or recreatable storage still belongs on a per-guest volume.
Guests get the mhelton user with passwordless sudo, so the root key is redundant. Tailscale SSH authenticates against tailnet identity rather than authorized_keys and is unaffected; VSOCK sessions now need an explicit login user, as `microvm -s <name>` defaults to root.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three changes that belong to the microvm foundation rather than to any one guest, split out so the guest that motivated them stays reviewable on its own. All are no-ops for every host that exists today.
Factor the mhelton user into its own module
The user and its authorized keys lived in
hosts/common/default.nix, which is a full host baseline — sops with theattic_pullsecret feedingnix.settings.netrc-file, the substituter list, a node exporter, systemPackages. A microvm guest wants the user and none of the rest, and importing the baseline would mean adding every guest as a sops recipient and re-encrypting.hosts/common/mhelton.nixnow carries the user,wheel, the keys, and passwordless sudo as amkDefault. The baseline imports it and keeps only its host-specific groups, which merge on top; its existingmkForce falsefor sudo still wins. Guests import the same file directly.Passwordless sudo comes along because the account has no password in a guest, so
sudowould otherwise prompt for something that does not exist — and setting one would pull sops back in.hosts/common/darwin.nixstill has its own copy of the keys. It is nix-darwin with a differentusers.usersschema, so folding it in is not a no-op and is left alone.Drop the root key from guests
With the mhelton user and passwordless sudo in place the root key is redundant. Tailscale SSH authenticates against tailnet identity rather than
authorized_keys, so tailnet access is unaffected.The one behaviour change:
microvm -s <name>defaults to-l root, so VSOCK sessions now needmicrovm -s <name> -- -l mhelton.Raise the guest state volume to 16G
/var/libis where NixOS modules put their state, so any guest running an ordinary service writes there whether or not it was planned for, and #118 sized it for identity alone. Volumes are sparse, and microvm only creates them when missing — a guest that boots with a small/var/libcannot be grown from Nix afterwards, only by hand withtruncateandresize2fs.The declared size is not entirely free, since
mkfs.ext4preallocates metadata proportional to it — measured at roughly 0.8%:16G is meant as a sane default rather than a ceiling. Guests needing more should append their own volume, which requires no
mkForcebecausemicrovm.volumesis a list and merges by concatenation. Overriding/var/libitself is possible withlib.mkForceon the whole list, but discards anything added here later.Verification
system.build.toplevel.drvPathwas captured for all seven hosts onmain, the changes applied, and re-evaluated:Byte-identical derivations across every host, so the
extraGroupsmerge reproduces the original exactly. Re-checked after each commit. Themicrovm/common.nixchanges are additionally unreferenced onmain, sincemicrovm/default.nixdoes not import it until a guest exists.