Skip to content

research: NixOS / non-FHS hardware acceleration dependency gaps #891

Closed

Description

@zackees

Summary

On NixOS 26.05 (KDE Wayland, RTX 3060, NVIDIA 595.99.02) the OBS-Studio-Rust AppImage (beta.20261014, via a buildFHSEnv/bubblewrap wrapper + nix-ld) rendered on Mesa llvmpipe at ~10 fps with no UI hint (#846). Root cause: libEGL_nvidia could not find the egl-wayland external platform JSONs, which NixOS keeps under /run/opengl-driver/share/egl/egl_external_platform.d. #722 (2fd806d) added host driver config discovery to AppRun. This research checks every hardware path against non-FHS hosts (NixOS, Guix) and sandboxes (Flatpak, bwrap FHS envs).

Conclusion: AppRun now finds driver configs (EGL vendor/platform JSON, GBM, VA, Vulkan ICDs) but not driver libraries (libcuda, libnvidia-encode, libGL*, libwayland-client). Those are excluded from the bundle and are left to the host loader path. On NixOS that path is nix-ld's NIX_LD_LIBRARY_PATH, which by default holds Mesa/glvnd but not /run/opengl-driver/lib (libcuda, libnvidia-encode) and not libwayland-client. Every failure except "graphics init failed" ends in a silent fallback (llvmpipe, x264, CPU decode, SHM capture). Nothing at startup detects it.

Evidence collected read-only on origin/master (2fd806d is the last AppRun change) and on the affected NixOS host.

Host facts (this NixOS machine)

  • /run/opengl-driver/lib has libcuda.so.1, libnvidia-encode.so.1, libnvcuvid.so.1, libEGL_nvidia.so.0, libnvidia-egl-wayland2.so.1, libnvidia-egl-gbm.so.1.
  • /run/opengl-driver/lib/dri has Mesa DRI + nvidia_drv_video.so, nouveau_drv_video.so, d3d12_drv_video.so; /run/opengl-driver/lib/gbm has dri_gbm.so, nvidia-drm_gbm.so.
  • /run/opengl-driver/share/egl/egl_external_platform.d: 09_nvidia_wayland2.json 10_nvidia_wayland.json 15_nvidia_gbm.json 20_nvidia_xcb.json 20_nvidia_xlib.json. /usr/share/egl and /usr/lib do not exist.
  • /run/opengl-driver/share/glvnd/egl_vendor.d: 10_nvidia.json 50_mesa.json; Vulkan ICDs include nvidia_icd.json and lvp_icd (lavapipe, software).
  • /run/opengl-driver-32 absent (no 32-bit; irrelevant for OBS x86_64).
  • NIX_LD_LIBRARY_PATH=/run/current-system/sw/share/nix-ld/lib: contains libEGL.so.1, libGL.so.1, libGLX*, libgbm, libdrm*, libvulkan.so.1, Mesa Vulkan drivers. Contains no libwayland* (0 matches), no libcuda, no libnvidia-encode.

Gap table

Path How located NixOS status after #722 Failure mode Proposed fix
EGL vendor (glvnd) __EGL_VENDOR_LIBRARY_DIRS; AppRun:130-133 adds /run/opengl-driver/share/glvnd/egl_vendor.d OK (config). Vendor JSON names libEGL_nvidia.so.0 by soname, so the lib must still be on the loader path Silent -> Mesa -> llvmpipe AppRun: add /run/opengl-driver/lib to the host lib search (see below)
EGL external platforms (egl-wayland/egl-gbm/xcb) __EGL_EXTERNAL_PLATFORM_CONFIG_DIRS; AppRun:135-138 Fixed by #722 (the original bug) Silent -> Mesa claims display -> llvmpipe Done; add regression test with fake tree
GLX (X11 sessions) glvnd libGLX_<vendor> chosen by X server, loaded by soname Depends on loader path; libGLX_nvidia lives only in /run/opengl-driver/lib Silent -> libGLX_mesa llvmpipe Same lib-path fix
Mesa DRI drivers Mesa built-in path (/run/opengl-driver/lib/dri on Nix Mesa) or LIBGL_DRIVERS_PATH OK with Nix Mesa; a non-Nix Mesa would not find them Silent -> swrast/llvmpipe (egl: failed to create dri2 screen) Set LIBGL_DRIVERS_PATH only if unset, like VA
GBM backends GBM_BACKENDS_PATH; AppRun:120-123 OK Silent (EGL GBM platform fallback) Done
libwayland-client/egl Excluded from bundle (assemble-appdir.sh:50 EXCLUDE), resolved from host loader path Missing: not in nix-ld lib; extracted AppImage fails libwayland-client.so.0: cannot open shared object file Loud (no start) when run outside the FHS env Bundle libwayland-client (ABI-stable, AppImage excludelist dropped it long ago) or add host dirs; at minimum check and print a clear message in AppRun
NVENC (libcuda.so.1, libnvidia-encode.so.1) os_dlopen by soname: plugins/obs-nvenc/cuda-load.c:15, plugins/obs-ffmpeg/obs-ffmpeg.c:262/268; excluded from bundle Not covered: only in /run/opengl-driver/lib, which neither AppRun nor default nix-ld adds Silent: encoder not registered; settings only list available encoders (frontend/settings/OBSBasicSettings.cpp:5054ff), simple-mode fallback picks x264 (OBSBasicSettings_Stream.cpp:1661/1706) AppRun: append /run/opengl-driver/lib (and /run/opengl-driver-32/lib n/a) to the host lib path for the host loader via --library-path or a scoped LD_LIBRARY_PATH only for obs, not children; NixOS docs hardware.graphics + programs.nix-ld.libraries
NVDEC/CUDA (media source hw decode) libnvcuvid/libcuda via FFmpeg dlopen Same as NVENC Silent -> CPU decode Same
VA-API LIBVA_DRIVERS_PATH; AppRun:125-128; libva excluded from bundle; vaInitialize plugins/obs-ffmpeg/vaapi-utils.c:95 Driver dir OK. libva.so.2 is not in default nix-ld lib -> host loader may not find it. NVIDIA needs nvidia_drv_video.so (nvidia-vaapi-driver), which is NVDEC-only (no encode) Silent: VAAPI encoders absent from list Lib-path fix; doc hardware.graphics.extraPackages (intel-media-driver, mesa)
Vulkan ICDs VK_DRIVER_FILES; AppRun:141-144 OK (config). nvidia_icd.json points at libGLX_nvidia.so.0 by soname -> lib path again. lavapipe ICD present, so a Vulkan consumer can silently land on CPU Silent Lib-path fix; prefer hw ICD, flag lvp as software
AMF (AMD) libamfrt64.so.1 dlopen Not packaged in nixpkgs by default (amf in amdenc/proprietary); not on any Nix path Silent (encoder absent) Doc only
QSV / oneVPL libvpl dispatcher + libmfx-gen/onevpl-intel-gpu runtime, searched via ONEVPL_SEARCH_PATH / system dirs Not handled by AppRun; NixOS keeps runtime in /run/opengl-driver/lib if in hardware.graphics.extraPackages Silent Add ONEVPL_SEARCH_PATH=/run/opengl-driver/lib when unset
PipeWire/portal capture DMA-BUF linux-pipewire imports DMA-BUF through EGL (gs_texture_create_from_dmabuf); renegotiates (pipewire.c:580, 1474) and drops modifiers on failure Works only if EGL is on the hw driver; on llvmpipe DMA-BUF import fails Silent -> SHM/memfd copy, extra CPU Covered by status light: log + flag "DMA-BUF disabled"
v4l2 MJPEG hw decode linux-v4l2 via FFmpeg hwaccel (VA-API) Depends on VA-API Silent -> CPU MJPEG decode Covered by VA-API fix + status light
CEF / browser source GPU CEF GPU process; uses its own ANGLE/EGL, often disabled on Linux (--disable-gpu) Inherits same EGL env; on miss Chromium uses SwiftShader Silent Status light should include browser GPU state (chrome://gpu equivalent)
Renderer detection libobs-opengl/gl-subsystem.c:274-277 logs Loading up OpenGL on adapter %s %s only No check Silent (log line only) #846 + startup warning

Sandbox notes

  • buildFHSEnv/bwrap: /run/opengl-driver is bind-mounted, but /usr/share/egl etc. are not populated from it; before appimage: use host VA drivers with audited FFmpeg compatibility and GPU checks #722 this was the bug. Libraries in /run/opengl-driver/lib are only on the path if the FHS env's ld.so.conf/profile adds it (nixpkgs buildFHSEnv does add /run/opengl-driver/lib via its LD_LIBRARY_PATH profile; plain bwrap does not).
  • nix-ld: only programs.nix-ld.libraries; driver libs need /run/opengl-driver/lib added explicitly (or NIX_LD_LIBRARY_PATH extended).
  • Guix: no /run/opengl-driver; drivers via profile (~/.guix-profile/lib, share/glvnd/egl_vendor.d) and the NVIDIA channel (nonguix) - AppRun probes nothing there.
  • Flatpak: uses GL extension runtimes (org.freedesktop.Platform.GL.nvidia-<ver>); mismatch with host driver version silently falls back to llvmpipe. Not an AppImage concern but the same status light applies.

Gaps in tests and diagnostics

  • build-aux/appimage/gpu-test.c ("Physical GPU checks ... No software fallback") exists, but CI's test-appimage.sh:466 sets LIBGL_ALWAYS_SOFTWARE=1 because CI has no GPU, so no lane asserts "not llvmpipe".
  • No test exercises a NixOS-shaped tree (/run/opengl-driver/... with no /usr/share/egl).
  • No startup self-check; no NVENC-missing-with-NVIDIA-GPU warning.

Options

Option Pros Cons
A. AppRun discovery (current) Zero user setup; already handles configs Shell heuristics per distro; does not cover libraries; cannot verify the result
B. Startup self-check (warn/refuse llvmpipe when a GPU exists) Catches every cause, any packaging, any distro; turns silent into loud Needs GPU detection (sysfs PCI 10de/1002/8086, /dev/dri/renderD*); must not block VMs/headless (warning + opt-out env, not hard refusal by default)
C. Official Nix flake/package (addDriverRunpath, wrapProgram with driver env) Correct-by-construction on NixOS; what nixpkgs obs-studio does Maintenance; only NixOS; users of the AppImage still need A/B
D. NixOS docs Cheap Users don't read docs before hitting the bug
E. CI NixOS lane with fake driver tree Prevents regression of A Can't prove real GPU use without hardware; needs a fake vendor EGL/ICD stub

Recommendation

  1. B first (it is frontend: GPU acceleration status light (green/yellow/red) in the status bar #846 plus a log-level warning): it is the only thing that satisfies "never silently fall back", whatever the packaging. Default: loud warning + status light yellow; OBS_REQUIRE_HW_GL=1 to refuse to start.
  2. Extend A to libraries: when the host loader is used and /run/opengl-driver/lib exists, pass it to the obs process only (loader --library-path or AppRun-scoped env removed before spawning children), plus LIBGL_DRIVERS_PATH, ONEVPL_SEARCH_PATH. Bundle or loudly check libwayland-client.
  3. E: add a test-appimage lane with a NixOS-shaped fake tree (no /usr/share/egl, configs under /run/opengl-driver, a stub vendor) asserting AppRun exports the dirs and that libcuda/libnvidia-encode names resolve.
  4. C + D later: a flake in-repo (nix/) using autoPatchelfHook/addDriverRunpath, and a NixOS section in the AppImage README.

Proposed follow-up issues

  • bug: appimage: NVENC/NVDEC silently missing on NixOS (libcuda/libnvidia-encode only in /run/opengl-driver/lib)
  • bug: appimage: extracted AppImage fails on NixOS, libwayland-client.so.0 not found (bundle or check)
  • appimage: AppRun sets LIBGL_DRIVERS_PATH and ONEVPL_SEARCH_PATH from /run/opengl-driver when unset
  • test: test-appimage NixOS-shaped fake driver tree lane (assert env + soname resolution)
  • libobs/frontend: startup software-renderer warning + OBS_REQUIRE_HW_GL (feeds frontend: GPU acceleration status light (green/yellow/red) in the status bar #846)
  • frontend: warn when an NVIDIA GPU is present but no NVENC encoder registered (and same for VA-API on Intel/AMD)
  • docs: NixOS / Guix / Flatpak hardware acceleration guide (hardware.graphics, nix-ld libraries)
  • packaging: evaluate an official Nix flake with addDriverRunpath

Refs #846, #722, #625, #520.

Activity

  1. zackees commented on Oct 23, 2026

    @zackees
    MemberAuthor

    Measured on 2026-10-23 with the released OBS-Studio-Rust-0.1.0-beta.20261023 AppImage, NixOS (RTX 3060 + RTX 2080 Ti, driver 595.99.02), under Xvfb:

    • appimage-run (nixpkgs): OBS renders on hardware (Loading up OpenGL on adapter NVIDIA Corporation NVIDIA GeForce RTX 3060/PCIe/SSE2), and NVENC registers: [obs-nvenc] NVENC version: 13.0 (compiled) / 13.0 (driver), CUDA driver version: 13.20, with obs_nvenc_h264_tex and obs_nvenc_hevc_tex. So the row "NVENC/NVDEC silently missing" doesn't happen through appimage-run, whose FHS env puts /run/opengl-driver/lib on the path.
    • Direct run with nix-ld (default NIX_LD_LIBRARY_PATH, no wayland): no longer a silent or confusing failure. The host-library preflight refuses with a clear fix: libwayland-client.so.0 ... run through appimage-run or nix-ld (programs.nix-ld.libraries = [ pkgs.wayland ]). The "extracted AppImage fails on libwayland-client" row now gets a clear message.
    • Done since this report: NVML usage from /run/opengl-driver/lib (obs-gpu-status: NVIDIA GPU utilization through NVML #1233, checked by the NixOS lane in test(appimage): NixOS lane checks OBS loads NVML from /run/opengl-driver (#1028) #1971), and a NixOS-shaped /run/opengl-driver tree in CI (test-appimage-nixos.sh, plus first-start's fake tree).

    Still open from the list: NVENC under nix-ld when the user adds wayland but not /run/opengl-driver/lib (AppRun doesn't add it to the library path), LIBGL_DRIVERS_PATH/ONEVPL_SEARCH_PATH from /run/opengl-driver, and the docs.

  2. added
    P3
    size:S
    on Oct 25, 2026
  3. zackees commented on Oct 25, 2026

    @zackees
    MemberAuthor

    /ready

    Triage: the research is done and measured (2026-10-23 comment), and most rows are already fixed (#722, #1233, #1971, the nix-ld preflight message). What's left is concrete:

    1. AppRun adds /run/opengl-driver/lib to the library path when it exists (NVENC under nix-ld without appimage-run).
    2. LIBGL_DRIVERS_PATH / ONEVPL_SEARCH_PATH from /run/opengl-driver.
    3. Docs for NixOS users.
      Acceptance for 1 and 2: test-appimage-nixos.sh covers them (per AGENTS.md's packaging rule, shown failing without the change). P3, size:S.
  4. added
    ready
    on Oct 25, 2026
  5. zackees commented on Oct 26, 2026

    @zackees
    MemberAuthor

    Status of the triage list:

    1. NVENC under nix-ld without /run/opengl-driver/lib: done in build-aux: AppRun adds the NixOS driver libraries to nix-ld's path (#891) #2436 (merged). AppRun appends the directory to NIX_LD_LIBRARY_PATH. On an RTX 3060 (driver 595.99.02) with the packaged AppImage, the log said "NVENC not supported" before and shows NVENC 13.0 with H.264 and HEVC after. Also fixed along the way: appimage: crashes at start on NixOS Wayland: bundled libxkbcommon finds no keyboard data (/usr/share/X11/xkb) #2437, the crash at start on NixOS Wayland from missing xkb data (build-aux: AppRun points libxkbcommon at the host's keyboard data (#2437) #2439, merged).
    2. LIBGL_DRIVERS_PATH and ONEVPL_SEARCH_PATH: I propose dropping both.
    3. Docs: README: How to run the AppImage on NixOS (#891) #2440 adds a README entry for NixOS.

    Once #2440 merges, this can close unless someone wants item 2 kept.

  6. zackees commented on Oct 26, 2026

    @zackees
    MemberAuthor

    #2440 merged. With #2436 and #2439 that covers items 1 and 3. Item 2 was dropped for the reasons in the previous comment; reopen if you want it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3readysize:S

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions