`nix build .#checks.x86_64-linux.vm-basic` failed because Hyprland 0.56.2
aborted with `CBackend::create() failed!` on every start. Reading aquamarine
0.15.1 rather than guessing at it, that abort had three independent causes on a
NixOS test machine, and none of them is visible in the journal until
`debug:disable_logs = false` is set -- Hyprland mutes aquamarine, so the abort
is all that survives. checks/lib/gpu-session.nix now supplies all three and
records the evidence for each:
* `-vga virtio`, for a DRM render node. `virtualisation.graphics = false`
still leaves QEMU's default bochs-drm adapter, which gives card0 and no
renderD*. Measured in the guest: `-vga virtio` -> card0 + renderD128;
`-device virtio-gpu-pci` only *adds* a card next to bochs-drm, so it would
need `-vga none` beside it.
* `hardware.graphics.enable`, so Mesa's GBM backends exist at all. Without it
gbm_create_device() fails with "MESA-LOADER: failed to open dri:
/run/opengl-driver/lib/gbm/dri_gbm.so" and aquamarine reports "Cannot open
backend: no allocator available".
* `SEATD_VTBOUND=0`, so libseat's embedded seatd hands out a seat with no VT.
`CHeadlessBackend::drmFD()` returns -1 unconditionally, so the *only*
source of an allocator is the DRM backend, which opens /dev/dri/card0
through libseat -- and the default VT-bound seat needs /dev/tty0, which the
unprivileged service user cannot open.
The diagnostics dump grows a "graphics devices" section (`ls -l /dev/dri`,
`cat /proc/fb`) and a "wayland socket vs WAYLAND_DISPLAY" section, so the next
machine that is missing a render node, or that binds a socket the frame server
is not waiting on, says so in three lines instead of timing out mutely.
vm-basic's `dump()` is now vm-hyprland's, which reports the exit status too.
vm-basic also gained `python3` in the guest: its last subtest shells out to a
python one-liner and had been dying on exit code 127 -- invisible until the
compositor got far enough to reach that subtest.
Neither check passes yet, and the two remaining blockers both live in
nix/module.nix, which this slice may not edit, so they are reported rather
than patched:
* vm-basic stops at "the module's two units come up". The compositor is up
and healthy; the frame server sits in ExecStartPre forever. The module
hardcodes `waylandDisplay = "wayland-0"`, but Hyprland's socket loop is
`// get socket, avoid using 0` over candidates 1..32 (src/Compositor.cpp),
so the session binds wayland-1. Forcing WAYLAND_DISPLAY=wayland-1 in the
guest was verified to carry vm-basic through every other subtest.
* vm-hyprland stops at "the compositor reports the configured headless
output" with "hyprctl never reported a HEADLESS-1 monitor". hyprctl reports
`Monitor Virtual-1` at 1280x800 -- the virtio-gpu output. A HEADLESS-N
output only exists after `hyprctl output create headless`, which the module
never issues; Hyprland's own fallback output is named FALLBACK. The
`monitor = HEADLESS-1, ...` line in hyprland.conf is a rule for a monitor
that is never created.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018fJZYyS4pqxt2FC37JsFYd
161 lines
5.4 KiB
Nix
161 lines
5.4 KiB
Nix
# checks.<system>.vm-hyprland -- the real one. Same machine as vm-basic, but no
|
|
# `captureCommand` override, so the server captures the actual headless
|
|
# compositor through grim.
|
|
#
|
|
# This is the check expected to be flaky, so it is deliberately impatient: every
|
|
# wait has a bounded timeout, nothing is retried in a loop, and any failure dumps
|
|
# the compositor's log and `hyprctl monitors` before it propagates. A flake you
|
|
# can read is worth more than a flake that eventually goes green.
|
|
{
|
|
testers,
|
|
hhstream,
|
|
testTools,
|
|
hhsModule,
|
|
hyprland,
|
|
grim,
|
|
width ? 1280,
|
|
height ? 720,
|
|
fps ? 30,
|
|
socketPath ? "/run/hyprland-headless-stream/stream.sock",
|
|
}:
|
|
testers.runNixOSTest {
|
|
name = "hhstream-vm-hyprland";
|
|
|
|
globalTimeout = 1800;
|
|
|
|
nodes.machine = {
|
|
# gpu-session.nix is what makes the compositor able to start at all; see
|
|
# that file for the three things a bare test machine is missing.
|
|
imports = [ hhsModule ./lib/gpu-session.nix ];
|
|
|
|
services.hyprland-headless-stream = {
|
|
enable = true;
|
|
package = hhstream;
|
|
hyprlandPackage = hyprland;
|
|
inherit socketPath;
|
|
frameRate = fps;
|
|
format = "png";
|
|
outputs = [
|
|
{
|
|
name = "HEADLESS-1";
|
|
inherit width height;
|
|
refresh = fps;
|
|
}
|
|
];
|
|
# No captureCommand: the module's default (grim) is the point of this check.
|
|
};
|
|
|
|
# hyprctl and grim are here for the diagnostics dump and for the manual
|
|
# cross-check below, not for the code path under test.
|
|
environment.systemPackages = [
|
|
testTools
|
|
hhstream
|
|
hyprland
|
|
grim
|
|
];
|
|
|
|
# The compositor needs more room than the fake capture did, and its software
|
|
# renderer wants a CPU. The virtio GPU from gpu-session.nix is there for its
|
|
# render node and its DRM backend, not for acceleration: rendering is still
|
|
# Mesa's software path.
|
|
virtualisation = {
|
|
memorySize = 2048;
|
|
cores = 2;
|
|
diskSize = 4096;
|
|
graphics = false;
|
|
};
|
|
};
|
|
|
|
testScript = ''
|
|
SOCKET = "${socketPath}"
|
|
WIDTH, HEIGHT = ${toString width}, ${toString height}
|
|
|
|
|
|
def dump(label):
|
|
print(f"########## diagnostics: {label} ##########")
|
|
status, out = machine.execute("hhs-hyprland-diagnostics", timeout=120)
|
|
print(out)
|
|
print(f"########## end diagnostics (exit {status}) ##########")
|
|
|
|
|
|
start_all()
|
|
|
|
with subtest("the compositor unit comes up"):
|
|
try:
|
|
machine.wait_for_unit("hyprland-headless.service", timeout=180)
|
|
except Exception:
|
|
dump("hyprland-headless.service did not start")
|
|
raise
|
|
|
|
with subtest("the compositor reports the configured headless output"):
|
|
try:
|
|
# Proves the compositor is really running a 1280x720 HEADLESS-1
|
|
# before we blame the capture for a wrong-sized frame.
|
|
out = machine.succeed("hhs-hyprland-diagnostics", timeout=120)
|
|
print(out)
|
|
assert "HEADLESS-1" in out, (
|
|
"hyprctl never reported a HEADLESS-1 monitor; see the dump above"
|
|
)
|
|
assert f"{WIDTH}x{HEIGHT}" in out, (
|
|
f"hyprctl never reported a {WIDTH}x{HEIGHT} mode; see the dump above"
|
|
)
|
|
except Exception:
|
|
dump("compositor output not as configured")
|
|
raise
|
|
|
|
with subtest("the frame server unit comes up and publishes the socket"):
|
|
try:
|
|
machine.wait_for_unit("hyprland-headless-stream.service", timeout=180)
|
|
machine.wait_for_file(SOCKET, timeout=120)
|
|
except Exception:
|
|
dump("frame server did not publish the socket")
|
|
raise
|
|
|
|
with subtest("grim can capture the session at all"):
|
|
# Separates "grim cannot see the compositor" from "the server is wrong",
|
|
# which are the two failures that look identical from the socket.
|
|
try:
|
|
print(
|
|
machine.succeed(
|
|
"systemd-run --pipe --wait --uid=hhstream"
|
|
" --setenv=XDG_RUNTIME_DIR=/run/user/$(id -u hhstream)"
|
|
" grim -t png /tmp/direct.png 2>&1 || true",
|
|
timeout=120,
|
|
)
|
|
)
|
|
print(machine.execute("stat -c '%s bytes' /tmp/direct.png")[1])
|
|
except Exception:
|
|
dump("direct grim capture failed")
|
|
raise
|
|
|
|
with subtest("a frame off the socket is a real PNG of the configured size"):
|
|
try:
|
|
print(
|
|
machine.succeed(
|
|
f"hhs-assert-stream --socket {SOCKET} --frames 1 --timeout 60"
|
|
f" --expect-width {WIDTH} --expect-height {HEIGHT}"
|
|
" --expect-format image/png --require-png --reject-blank",
|
|
timeout=180,
|
|
)
|
|
)
|
|
except Exception:
|
|
dump("frame off the socket failed the PNG assertions")
|
|
raise
|
|
|
|
with subtest("the stream keeps producing frames"):
|
|
try:
|
|
print(
|
|
machine.succeed(
|
|
f"hhs-assert-stream --socket {SOCKET} --frames 3 --timeout 60"
|
|
f" --expect-width {WIDTH} --expect-height {HEIGHT}"
|
|
" --require-png --reject-blank",
|
|
timeout=240,
|
|
)
|
|
)
|
|
machine.succeed("systemctl is-active hyprland-headless-stream.service")
|
|
except Exception:
|
|
dump("the stream stopped after the first frame")
|
|
raise
|
|
'';
|
|
}
|