#!/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//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 /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