docs(repo): trying komorebi in a virtual machine

The guide for the one command: docs/trying-it.md says what a machine needs to
run the demo guest, with the lines of .wslconfig and of the NixOS-WSL
configuration for Windows 11, how to check it with `run-kde --doctor`, what the
command does and shows, the key bindings to try, how the GPU path is chosen, how
to open Windows' own RDP client, how long the first run takes (measured on a
machine with 32 cores and an empty store, by number of cores, with an estimate
for a WSL 2 machine and its caveats), how to start again, how to work on
komorebi in the guest, and what to do when something is wrong, by symptom. It
ends with what was run and what was not: nothing has been run on WSL 2 yet. The
README has a section and a link, and the user guide index a line.

DESIGN.md has four entries. Two record what I decided and want: the QEMU window
first and RDP second, and the GPU wherever the host has one. Two say that a
reason was not written down, for QEMU with KVM and not Hyper-V and for sharing
the password by a directory, and what is known that bears on each; the password
entry also says why a password is made for each user. PLATFORM.md has a section
for WSL 2 with what the command expects, a table of the probe results still to
be recorded (KVM, display, GPU, RDP, resources, virtiofs), and what is known of
virtiofsd without WSL 2.
This commit is contained in:
LGUG2Z committed 2026-10-28 14:20:08 -07:00
1 parent 0e8e25957c
commit 1ee2405e44
10 files changed
+366 -7

No files matched your search

+52
View File
@@ -834,6 +834,58 @@ a Linux builder that is itself a virtual machine on the Mac, as `darwin.linux-bu
nested KVM. `nixos-install` is a plain program, in a guest that runs at the speed of the Mac's own
virtualization.
## Why does `run-kde` start the guest in QEMU with KVM, and not in Hyper-V?
The guest is started from a NixOS machine in WSL 2 that has this repository checked out: that is the
machine I named (Windows 11, an AMD CPU, the latest NixOS-WSL, x86_64), and the command is meant to
need nothing else set up. The flake already builds the Plasma guests as a QEMU runner that boots
the system from the host's Nix store, and the VM tests boot the same guests under QEMU with KVM,
so the command starts what CI boots. KVM is what WSL 2 offers inside its own virtual machine when
nested virtualization is on. The command needs it, and refuses to start without it, since Plasma
under software emulation is too slow to try anything; `--tcg` allows it anyway.
Why not Hyper-V, whose virtual machines Windows itself runs? Nobody wrote down a reason, and this
entry does not make one up. What is known is that a Hyper-V guest would be another artifact, a disk
image that Windows' hypervisor boots, and that the repository builds none. The reason for
choosing QEMU over it still needs to be written down.
## Why is the QEMU window the first way to see the guest, and RDP the second?
I decided that the primary view is the QEMU window through WSLg, and that RDP from
Windows (`mstsc`) comes second. The reason was not written down. What bears on it is known: the
guest's RDP server, KRDP, sends H.264 video only, encoded in software on the guest's CPUs when there
is no VAAPI device, FreeRDP built with OpenH264 shows nothing of it, and nobody has tried Windows'
client against it ([PLATFORM.md](PLATFORM.md#rdp-into-the-session)). A window of QEMU has no video
encoder between the guest and the screen. How fast the window is through WSLg has not been
measured: the plan has the probe's number decide which is the default.
## Why does the guest use the GPU wherever the host has one?
Because I want GPU accel where it's available on the host. So the GPU path is part of the design and
not an opt-in: `run-kde` looks for it (`/dev/dxg` on WSL 2, a render node elsewhere, and a host
OpenGL that is not llvmpipe) and starts the guest with `virtio-vga-gl` and QEMU's GTK window with
OpenGL, which gives KWin in the guest real OpenGL through VirGL. When the host has none, it starts the
guest with a software `virtio-vga` and says why. `--gpu auto|on|off` overrides the choice, and KVM is
needed either way.
The display device is not part of the guest. The runner of nixpkgs would fix it when the guest is
built, so the demo guest leaves it out, and `run-kde` gives the runner the device when it starts
the guest: one closure and one disk serve both paths.
## Why is the password made for each user, and shared by a directory?
A guest's closure is in the Nix store of whoever builds it, which every user of that machine can
read, so a password or a key in it would be known to all of them, and would be the same for everyone
who runs the demo. The Plasma guests carry no key and no password already
([utm.md](utm.md)). `run-kde` makes a random RDP password and an ssh key pair when it makes the state
directory, in files that only the user can read, and shares that directory with the guest, which
takes the two files when it boots. Why a shared directory and not another way to hand the guest a
secret was not written down; the guests already get the repository that way.
The guest copies the files as root, and does not read them where they are, because the user of the
host who owns the directory need not be the guest's user: with another owner, and the mode of 0700 the
directory has, the guest's user cannot read it.
## Why are binaries published only by this repository?
The Komorebi License allows anyone to distribute the source code, with changes, but not
+34
View File
@@ -850,6 +850,40 @@ and KRDP 6.8.1 and FreeRDP 3.32.2:
the session would send each key back to itself. Whether a key pressed in an RDP client reaches a
global shortcut is therefore not known; no check from a real client has been recorded.
## WSL 2
`run-kde` is written for NixOS in WSL 2 on Windows 11 with an AMD CPU and an x86_64 guest, and
nothing in this section has been measured on that machine yet. The table says what the command
expects and what is still to be recorded, as dated facts, from the probe
(`scripts/wsl2-probe.sh`) when somebody runs it there. The facts that were measured on a Linux machine
with KVM and no WSL, window or GPU are in [Rendering in virtual machines and over
RDP](#rendering-in-virtual-machines-and-over-rdp).
| Probe | What the command expects | Result |
|---|---|---|
| KVM | `/dev/kvm` is there with `nestedVirtualization=true` in `.wslconfig`, the CPU flags show `svm`, and the user is in the group `kvm` | to be recorded |
| KVM | QEMU with `-accel kvm` boots a kernel; how fast a CPU loop runs in the guest against WSL | to be recorded |
| Display | `WAYLAND_DISPLAY` or `DISPLAY` is set by WSLg, and QEMU's GTK window opens | to be recorded |
| Display | the keyboard and the pointer work in the window, and Ctrl + Alt + g grabs and releases them; the frame rate of a moving window | to be recorded |
| GPU | `/dev/dxg` is there, `wsl.useWindowsDriver = true` is in effect, and the host's OpenGL renderer string is d3d12 and not llvmpipe | to be recorded |
| GPU | `-device virtio-vga-gl -display gtk,gl=on` starts, and the guest's renderer is virgl; the frame rate with and without it | to be recorded |
| RDP | `localhost:3389` in Windows reaches the guest; Windows' client shows a picture of KRDP's H.264; keyboard layouts survive | to be recorded |
| Resources | free memory and disk in WSL, the values of `.wslconfig`, the time to build the guest, the size of its closure | to be recorded |
| virtiofs | `virtiofsd` starts as the user and serves `/nix/store` and a directory; the guest mounts both through virtio-fs devices, with its memory in a shared memfd, reads the store, and reads and writes the directory | to be recorded |
What is known of virtiofs without WSL 2 (nixpkgs' runner mounts the host's `/nix/store` and the
shared directories by virtiofs on a Linux host), at time of writing (2026-10-28): the chain that
the probe's P6 builds, `virtiofsd` 1.14.0 started as an ordinary user with the runner's options, and
a guest that mounts the host's `/nix/store` read-only and a directory read-write, passes on an
`x86_64` machine with KVM, on an `aarch64` machine and under TCG. `virtiofsd` prints two warnings
as an ordinary user (it cannot raise the limit of open files, and it cannot use file handles) and
never opens `/dev/fuse`. A file owned by the host user shows up in the guest with the same numeric
uid. The kernel configuration of WSL 2 (`linux-msft-wsl-6.6.y`, read, not run) has
`CONFIG_FUSE_FS=y`, `CONFIG_MEMFD_CREATE=y`, `CONFIG_USER_NS=y` and `CONFIG_KVM_AMD=m`.
One thing that the command depends on is not in the probe, and is not known either: whether
Windows or WSLg takes any of the Alt combinations of the key bindings before the window sees them.
## What was not measured
At time of writing (2026-10-28) these are gaps, not findings. Nothing on this page says that
+4 -2
View File
@@ -135,7 +135,8 @@ what a person's run needs comes from the environment of the runner:
| `QEMU_OPTS` | the display device: `-vga none -device virtio-vga,xres=1280,yres=800`, or `-display gtk,gl=on -vga none -device virtio-vga-gl,xres=1280,yres=800` for a GPU |
| `NIX_DISK_IMAGE` | the disk image, which the runner makes when it is not there |
[`run-kde`](#the-command) sets them; to start the guest by hand, on a Linux machine:
[`run-kde`](#the-command) sets them ([the guide](../trying-it.md) says what a person sees and does);
to start the guest by hand, on a Linux machine:
```sh
nix build .#nixosConfigurations.run-kde-x86_64.config.system.build.vm -o .vm/result-run-kde
@@ -190,7 +191,8 @@ In order, it:
to try anything.
2. Builds the guest when its runner is not in the store, with `nix build` of the checkout's flake and
the build log shown. There is no binary cache: the first run builds komorebi and downloads about
4 GB of Plasma, which are 11 GB in the Nix store.
4 GB of Plasma, which are 11 GB in the Nix store. [The first run](../trying-it.md#the-first-run)
says how long that took where it was measured.
3. Makes the state directory, `$XDG_STATE_HOME/komorebi-run-kde` (`~/.local/state/komorebi-run-kde`),
when it is not there: the guest's disk (20 GB, or `--size`, sparse), a random RDP password and an
ed25519 key for ssh, all of mode 0600 in a directory of mode 0700. `--reset` deletes it. Nothing