Repository navigation
Integrate microvm.nix guests - #136
Merged
Merged
Conversation
microvm.nix runs no module evaluation itself: a guest is a NixOS evaluation with its guest module, and its host module declares microvm.vms.<name> and reads the guest's runner, shares and toplevel. Two integrations bring guests into the tree, both evaluated by caisson's code. caisson-microvm, the native integration, is a configuration declared inside a NixOS host that holds similarly configured guests. Its options are what they share: hypervisor, vcpu, mem, interfaces and shares, typed as upstream types them, and the start options autostart (false), restartIfChanged (true) and runtimeMaxSec. Its default gives the nearest NixOS configurations beneath it caisson/microvm-guest, which imports upstream's guest module and defines its options from the configuration. slots.<kind> declares the guests <kind>-1 to <kind>-N from the registered configuration of the kind, each with its vsock CID and its shares under a directory of the slot, and passes the kind's moduleImports to them. microvm, the upstream-compatible integration, is the guest itself: a NixOS evaluation with upstream's guest module, whose modules set the microvm options as microvm.nix users write them. caisson/microvm-host, a NixOS module, defines microvm.vms.<guest> with evaluatedConfig for every guest that belongs to the host, sets the start options and RuntimeMaxSec, refuses upstream's config and flake forms for those names, and turns caisson.microvm-host.operators.<user> into a polkit rule that lets those users start and stop exactly their guests' units. Guests are published as nixosConfigurations.<guest> and are no colmena nodes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
microvm.nix runs no module evaluation itself. A guest is a NixOS evaluation with its guest module (
nixos-modules/microvm). Its host module (nixos-modules/host) declaresmicrovm.vms.<name>, and reads from each guest onlymicrovm.declaredRunner,microvm.sharesandsystem.build.toplevel. This adds the two integrations that bring guests into the caisson tree. Both are evaluated by caisson's code, and neither uses upstream's own guest evaluation.caisson-microvm, native. Type and classcaisson-microvm, namespacelib.caisson.caisson-microvm.caisson.caisson-microvm.configurations.<name>, and holds similarly configured guests ascaisson.nixos.configurations.<guest>.hypervisor,vcpu,mem,interfacesandsharesuse upstream's types and defaults, and say what the guests share. The start options areautostart(defaultfalse),restartIfChanged(defaulttrue) andruntimeMaxSec.caisson/microvm-guestto the nearest NixOS configurations beneath it, throughcaisson.forNearestChildren(Give configurations their nearest children's defaults #135). That module imports upstream's guest module from the resolved microvm.nix source, recorded as an ecosystem unit. It defines the guest's options from the configuration, read throughnearest.caisson-microvm.slots.<kind> = { count; cidBase; shareRoot; vsockPort; moduleImports; extraModuleImports; }declares the guests<kind>-1to<kind>-<count>fromlib.caisson.configs.nixos.<kind>. Each slot gets the vsock CIDcidBase + k. Each also gets its shares,<shareRoot>/<kind>-<k>/inread-only at/work/inand.../outat/work/out. The kind'smoduleImportsandextraModuleImportsare passed to every slot, so a guest kind can reset the selection a host's registrydefaultwould give it. A kind that resets listscaisson/microvm-guestitself.microvm, upstream-compatible. Typemicrovm, NixOS class, namespacelib.caisson.microvm. A configuration declared inside a host ascaisson.microvm.configurations.<name>is the guest itself: caisson's NixOS evaluation with upstream's guest module appended, whose modules set the microvm options as microvm.nix users write them.caisson/microvm-host. A NixOS module that a host selects to hold guests.microvm.vms.<guest>withevaluatedConfigfor every guest that belongs to the host, bybelongsHere.RuntimeMaxSeconmicrovm@<guest>.configandflakeforms for those names, and repeated guest names.caisson.microvm-host.operators.<user> = [ <guest> … ]becomes a polkit rule that lets each user start, stop and restart exactly those guests' units.Guests are published as
nixosConfigurations.<guest>, are no colmena nodes, and inherit none of their host's nearest defaults, such as a disk layout's file systems.Limits:
microvmguest. A configuration declared inside amicrovmguest that looks upnearest.nixos, such as a home-manager configuration, finds the host, since the guest's type ismicrovm.Tests (pinned world):
caissonMicrovmGuestsRunOnTheirHost: two plain guests and two slots in a host'smicrovm.vms, with toplevels matching the published ones, the start options, CIDs and shares, and values from the configuration.microvmConfigurationIsTheGuestmicrovmOperatorsGetExactlyTheirUnitsmicrovmSlotKindSelectsItsModulesmicrovmGuestsAreNoNodes: guests of a colmena node on a disk layout are no nodes and get neither the layout's file systems nor the deployment options.everyModuleCaissonAddsIsNamedis extended to the new integrations.tests/dependenciespins microvm.nix at4876e2a. Locally, the pinned world, nix-unit,nix flake check --no-build, eval-weight, argument-errors, drift-message andnix fmtpass. A qemu guest's runner builds, with the same drvPath through the host'smicrovm.vms. No VM boot has run yet.🤖 Generated with Claude Code