Files
hyprland-headless-stream-pl…/tests/hyprland_diagnostics.sh
T
HermenixandClaude Opus 5 a37b3dd485 checks: give both VM machines a virtio GPU, and say why when it is not enough
`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
2026-09-28 12:28:01 +00:00

110 lines
4.1 KiB
Bash
Executable File

#!/bin/sh
# Dump everything worth knowing when `vm-hyprland` fails.
#
# The compositor's own log is the thing you actually want and the thing that is
# hardest to find: Hyprland writes it under
# $XDG_RUNTIME_DIR/hypr/<instance-signature>/hyprland.log, and the service runs
# on a private XDG_RUNTIME_DIR. So rather than guess the path, look for it.
#
# Never fails: a diagnostics dump that exits non-zero hides the real error.
PATH="@diagPath@:$PATH"
export PATH
if [ "$1" = "--self-test" ]; then
echo "hhs-hyprland-diagnostics: ok"
exit 0
fi
SERVICE_UNIT=hyprland-headless-stream.service
COMPOSITOR_UNIT=hyprland-headless.service
say() { printf '\n----- %s -----\n' "$*"; }
run() { say "$*"; "$@" 2>&1 || echo "[exit $?]"; }
say "units"
systemctl --no-pager --plain list-units --all 'hyprland*' 2>&1 || true
for unit in "$COMPOSITOR_UNIT" "$SERVICE_UNIT"; do
run systemctl --no-pager --full status "$unit"
run journalctl --no-pager --boot --lines=200 --unit "$unit"
done
run systemctl --no-pager --full list-dependencies "$SERVICE_UNIT"
say "graphics devices"
# The one piece of hardware a headless Hyprland still needs. A NixOS test
# machine gets QEMU's default bochs-drm adapter, which gives a card0 and *no*
# renderD*; aquamarine's headless backend wants a render node and aborts with
# "CBackend::create() failed!" without one. So "card0 but no renderD128" here
# is the signature of a machine that needs a virtio GPU in qemu.options.
ls -l /dev/dri 2>&1 || echo "[no /dev/dri: this machine has no DRM device at all]"
run cat /proc/fb
say "socket and runtime directories"
ls -la /run/hyprland-headless-stream 2>&1 || echo "[no /run/hyprland-headless-stream]"
ls -la /run/user 2>&1 || echo "[no /run/user]"
for d in /run/user/*; do
[ -d "$d" ] && ls -la "$d" 2>&1
done
say "wayland socket vs WAYLAND_DISPLAY"
# The other silent killer: the frame server waits for
# $XDG_RUNTIME_DIR/$WAYLAND_DISPLAY, so if the compositor bound a different
# socket name the unit just sits in ExecStartPre until the test times out, with
# a healthy compositor next to it. Print both names side by side.
systemctl show -p Environment --value "$SERVICE_UNIT" 2>&1 \
| tr ' ' '\n' | grep -E '^(WAYLAND_DISPLAY|XDG_RUNTIME_DIR)=' \
|| echo "[no WAYLAND_DISPLAY/XDG_RUNTIME_DIR in the unit environment]"
for d in /run/hyprland-headless-stream /run/user/*; do
[ -d "$d" ] || continue
found_sock=$(find "$d" -xdev -maxdepth 1 -name 'wayland-*' ! -name '*.lock' 2>/dev/null)
if [ -n "$found_sock" ]; then
echo "bound sockets in $d: $found_sock"
else
echo "bound sockets in $d: [none]"
fi
done
say "hyprland logs"
# hyprland.log lives beside the compositor's IPC sockets; -xdev keeps this out
# of /nix/store and /proc.
found=0
for root in /run /var/log /tmp /home; do
[ -d "$root" ] || continue
for log in $(find "$root" -xdev -maxdepth 6 -name 'hyprland*.log' 2>/dev/null); do
found=1
say "tail -n 200 $log"
tail -n 200 "$log" 2>&1
done
done
[ "$found" = 1 ] || echo "[no hyprland*.log anywhere under /run /var/log /tmp /home]"
say "hyprctl monitors"
# Needs both XDG_RUNTIME_DIR and the instance signature, which is the directory
# name under <runtime>/hypr. Try every instance we can find.
tried=0
for hyprdir in /run/user/*/hypr/* /run/*/hypr/*; do
[ -d "$hyprdir" ] || continue
sig=$(basename "$hyprdir")
runtime=$(dirname "$(dirname "$hyprdir")")
owner=$(stat -c %U "$hyprdir" 2>/dev/null || echo root)
tried=1
say "hyprctl monitors (instance $sig, XDG_RUNTIME_DIR=$runtime, as $owner)"
if command -v hyprctl > /dev/null 2>&1; then
XDG_RUNTIME_DIR="$runtime" HYPRLAND_INSTANCE_SIGNATURE="$sig" \
hyprctl monitors 2>&1 || echo "[exit $?]"
XDG_RUNTIME_DIR="$runtime" HYPRLAND_INSTANCE_SIGNATURE="$sig" \
hyprctl version 2>&1 || echo "[exit $?]"
else
echo "[hyprctl not on PATH; add the hyprlandPackage to environment.systemPackages]"
fi
done
[ "$tried" = 1 ] || echo "[no hypr instance directory found: the compositor never came up]"
say "processes"
ps aux 2>&1 | grep -E 'hypr|hhstream|grim' | grep -v grep || echo "[no hyprland/hhstream/grim process]"
say "end of diagnostics"
exit 0