Files
hyprland-headless-stream-pl…/checks/lib/gpu-session.nix
T
HermenixandClaude Opus 5 6510e315d4 module: make outputs monitor rules for real connectors, and own the seat flag
A machine running this module has a GPU. aquamarine's headless backend has
no allocator of its own -- `CHeadlessBackend::drmFD()` returns -1 and
`CBackend::start()` takes the allocator from the first backend with a drm fd
-- so the session always rides on the DRM backend and always has the host's
own connectors. `HEADLESS-1` is a name no connector will ever have, which
made the shipped default a monitor rule Hyprland silently ignored, and made
`vm-hyprland`'s assertion on that name unsatisfiable.

`outputs` now means "monitor rules applied to whatever outputs the machine
has". `name` is a regex against the real connector names and defaults to the
empty string -- Hyprland's own wildcard form, as in its shipped
`monitor=,preferred,auto,1` -- so `enable = true` alone gives a session at a
known size on any host. Nothing else about the option changed.

SEATD_VTBOUND=0 moves from checks/lib/gpu-session.nix into the compositor
unit, where it belongs: libseat finds no seatd socket and no logind session
for a system service, falls back to its embedded seatd, and that seat is
VT-bound by default -- so it opens /dev/tty0, which the service user cannot,
and every device open is refused. That is true on any host, not just in the
test. gpu-session.nix keeps only the two things that really are the test
machine's business: a render node and Mesa.

vm-hyprland now asserts over `hyprctl -j monitors` that at least one monitor
exists at the configured mode, with no monitor name anywhere in the check.
It also gains a wallpaper, because `--reject-blank` could not otherwise mean
anything: the session the module configures by default is a flat black
field, which grim captures as an all-zero 1280x720 RGBA PNG of exactly 3653
bytes -- `blank_png_size()` to the byte. Runs that passed that assertion were
reading Hyprland's startup notification overlay, which expires after about
fifteen seconds. With `misc:force_default_wallpaper` on, the frame is 85267
bytes with all 921600 pixels non-zero and is byte-identical at +15s, +30s and
+60s.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01M5GEju6XhoRXDWvEiaAX2r
2026-09-28 21:51:24 +00:00

54 lines
2.7 KiB
Nix

# What a NixOS test machine has to be given before Hyprland 0.56.2 will start.
#
# Imported by both VM checks. It is a machine definition, not a test: nothing
# here relaxes anything either check asserts, it only supplies hardware and
# session facts that a default `nodes.machine` does not have.
#
# The failure it fixes is the same one every time -- the compositor aborts with
#
# terminate called after throwing an instance of 'std::runtime_error'
# what(): CBackend::create() failed!
#
# and systemd restarts it until the test's timeout expires. `CBackend::create()`
# is aquamarine's, and reading aquamarine 0.15.1 rather than guessing at it, it
# needs three separate things. Two of them are hardware the bare test machine
# does not have and are the blocks below; the third -- a seat that is not bound
# to a VT -- is true of this session on any host, so it lives in nix/module.nix
# as `SEATD_VTBOUND=0` on the compositor unit rather than here.
#
# A note for whoever hits this next: none of it is visible in the journal until
# you also set `debug:disable_logs = false`, because Hyprland mutes aquamarine
# by default and the abort is all that survives. That is how the three causes
# were separated.
{ ... }:
{
# 1. A DRM render node.
#
# `virtualisation.graphics = false` still leaves QEMU's default bochs-drm
# adapter in the guest, which offers /dev/dri/card0 and *no* renderD*. Measured
# in the guest, not assumed:
#
# (default) card0 (bochs-drm)
# -vga virtio card0, renderD128 (virtio_gpu)
# -device virtio-gpu-pci card0, card1, renderD128 (bochs + virtio)
# -vga none -device virtio-gpu-pci card0, renderD128 (virtio_gpu)
#
# `-vga virtio` *replaces* the default adapter, so it is the one-option form of
# the last line. `-device virtio-gpu-pci` on its own only *adds* a second card
# next to bochs-drm, so it would need `-vga none` beside it to leave the guest
# with a single DRM device.
virtualisation.qemu.options = [ "-vga virtio" ];
# 2. Mesa, where the GBM loader looks for it.
#
# aquamarine's allocator is gbm_create_device() on that node. On NixOS the GBM
# backends live under /run/opengl-driver, which only exists when
# hardware.graphics is enabled -- a test machine has it off. Without it:
#
# MESA-LOADER: failed to open dri: /run/opengl-driver/lib/gbm/dri_gbm.so:
# cannot open shared object file: No such file or directory
# ERR from aquamarine ]: Couldn't open a GBM device at fd 21
# CRIT from aquamarine ]: Cannot open backend: no allocator available
hardware.graphics.enable = true;
}