build(nix): guests for a Linux host

The Plasma guests were made for an Apple silicon Mac only: the flake fixed the
guest to aarch64-linux and the host of QEMU to the Mac. `mkPlasmaGuest` now
takes the system of the guest and the packages of the machine that runs QEMU,
and the flake has the two QEMU guests for a Linux machine with KVM as well:
plasma-vm-x86_64 and plasma-vm-session-x86_64, and the same pair for aarch64
(plasma-vm-aarch64, plasma-vm-session-aarch64). The three guests of a Mac keep
their names and are built from the same instructions.

An x86_64 machine has a VGA that QEMU adds unless it is told not to, which would
be a second display next to the virtio-gpu that KWin draws on. An x86_64 guest
therefore gets virtio-vga, a virtio-gpu that is also the VGA, and `-vga none`;
an aarch64 guest has no VGA and keeps virtio-gpu-pci.

plasma-guests-eval evaluates every guest and asserts what each is for: the
architecture of the guest, the system of its host, KVM or HVF, and one display
device. docs/dev/utm.md says which guest is for which host and how to build and
run one on a Linux machine; the README and CONTRIBUTING say that there are
guests for both.
This commit is contained in:
LGUG2Z committed 2026-10-28 13:27:11 -07:00
1 parent 9b60a0020d
commit 146e794b7b
5 files changed
+180 -53

No files matched your search

+19 -5
View File
@@ -8,7 +8,9 @@
# A NixOS Plasma 6 guest to develop and test against a real KWin, with komorebi installed by the
# flake's module, `services.komorebi`, from the flake's packages. The flake builds it for an Apple
# silicon Mac, which runs it under QEMU with HVF; docs/dev/utm.md says how to build and run it.
# silicon Mac, which runs it under QEMU with HVF, and for a Linux machine, which runs it under QEMU
# with KVM; docs/dev/utm.md says how to build and run it. The system of the guest and the packages
# of the machine that runs QEMU (`hostPkgs`) come from the flake, so that one file serves them all.
#
# The guest mounts the repository at /repo, and keeps its disk in the directory it is started
# from, which is best .vm (gitignored):
@@ -24,6 +26,20 @@
# komorebi in it, and it can be reached over RDP (krdp.nix).
let
cfg = config.komorebi.plasmaVm;
# The guest's one display, a virtio-gpu, so that KWin has a DRM device to draw on. The machine of
# an aarch64 guest has no display of its own. The machine of an x86_64 guest has a VGA, which QEMU
# adds unless it is told not to, and KWin would draw on it as well as on the virtio-gpu: a second
# head. An x86_64 guest gets `virtio-vga`, a virtio-gpu that is also the VGA, in its place.
gpu =
args:
if pkgs.stdenv.hostPlatform.isx86_64 then
[
"-vga none"
"-device virtio-vga${args}"
]
else
[ "-device virtio-gpu-pci${args}" ];
in
{
imports = [ ./krdp.nix ];
@@ -130,7 +146,7 @@ in
diskSize = 20 * 1024;
graphics = false;
# no display, but a gpu so there is a drm render node
qemu.options = lib.mkIf (!cfg.session) [ "-device virtio-gpu-pci" ];
qemu.options = lib.mkIf (!cfg.session) (gpu "");
forwardPorts = [
{
from = "host";
@@ -166,9 +182,7 @@ in
# kwin drives virtio-gpu through drm on the primary node; that is the only place mesa's software
# rasterizer can allocate buffers (see docs/dev/PLATFORM.md: the headless --virtual backend
# cannot)
virtualisation.vmVariant.virtualisation.qemu.options = [
"-device virtio-gpu-pci,xres=1920,yres=1080"
];
virtualisation.vmVariant.virtualisation.qemu.options = gpu ",xres=1920,yres=1080";
# an idle lock screen or dimmed display changes how kwin animates and what screenshots show
environment.etc."xdg/kscreenlockerrc".text = ''
[Daemon]