Skip to content

build-aux: AppRun adds the NixOS driver libraries to nix-ld's path (#891) - #2436

Merged
zackees merged 2 commits into
masterfrom
fix/891-nixos-driver-lib
Oct 26, 2026
Merged

zackees merged 2 commits into
masterfrom
fix/891-nixos-driver-lib

Conversation

@zackees

@zackees zackees commented Oct 26, 2026

Copy link
Copy Markdown
Member

Refs #891 (item 1 of the triage list: NVENC under nix-ld without /run/opengl-driver/lib).

Cause

Run directly on NixOS (not through appimage-run), AppRun's host mode copies the host loader, and on NixOS that loader is nix-ld. nix-ld searches only NIX_LD_LIBRARY_PATH, which by default holds /run/current-system/sw/share/nix-ld/lib and not the driver closure. obs-nvenc loads libcuda.so.1 and libnvidia-encode.so.1 by soname, so on NixOS it finds neither.

Fix

AppRun appends /run/opengl-driver/lib to NIX_LD_LIBRARY_PATH when that directory exists and the variable is set, meaning nix-ld is in use. A value that already lists the directory is left alone, and so is an unset one. Only nix-ld reads this variable, so unlike LD_LIBRARY_PATH it can't leak into host programs OBS starts. Appending keeps the user's entries first.

Tests

  • RED 4aa7d3d: test-apprun-driver-env.sh (run by ci.toml and by test-appimage.sh) now checks NIX_LD_LIBRARY_PATH in each of its three namespace cases. Before the fix, the nixos case fails: expected set:/nix/ld/default:/run/opengl-driver/lib, obs has set:/nix/ld/default.
  • GREEN d36b5ae: all three pass.
  • The real packaged app, on a NixOS 26.05 host (RTX 3060, driver 595.99.02). I used the master AppImage bb253a0 under Xvfb, with nix-ld's library path set to its default plus wayland, but not the driver directory:
    • Unchanged AppRun: Failed to initialize module 'obs-nvenc.so', NVENC not supported.
    • The same AppImage with this PR's AppRun block: [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 registered.
    • Both runs used Mesa for EGL (__EGL_VENDOR_LIBRARY_FILENAMES=.../50_mesa.json), because NVIDIA's EGL can't drive Xvfb. NVENC doesn't depend on the display.

Not in this PR: #891's items 2 (LIBGL_DRIVERS_PATH and ONEVPL_SEARCH_PATH) and 3 (NixOS docs).

Separately: started on a NixOS Wayland session, the same AppImage crashes in xkb_keymap_new after qt.qpa.wayland: failed to create xkb context, because NixOS has no /usr/share/X11/xkb. I'll file that on its own.

Under nix-ld (the AppImage run directly on NixOS, without appimage-run)
OBS's loader searches NIX_LD_LIBRARY_PATH, which lacks
/run/opengl-driver/lib, so obs-nvenc finds no libcuda.so.1 and NVENC is
missing. The nixos case fails: obs has set:/nix/ld/default.

Refs #891
Run directly on NixOS, OBS's loader is nix-ld, which searches only
NIX_LD_LIBRARY_PATH. AppRun now appends /run/opengl-driver/lib when it
exists and nix-ld is in use, so obs-nvenc finds libcuda.so.1 and
libnvidia-encode.so.1. Checked on an RTX 3060 (driver 595.99.02):
"NVENC not supported" before, NVENC 13.0 with H.264 and HEVC after.

Refs #891
@zackees
zackees enabled auto-merge October 26, 2026 02:49
@zackees
zackees added this pull request to the merge queue Oct 26, 2026
Merged via the queue into master with commit daab712 Oct 26, 2026
31 checks passed
rdoupe pushed a commit to rdoupe/obs-studio that referenced this pull request Oct 26, 2026
appimage-run, or directly through nix-ld with hardware.graphics and
Wayland in nix-ld's libraries. The driver libraries and keyboard data
need no setup since obs-rust#2436 and obs-rust#2439.

Refs obs-rust#891
@zackees
zackees deleted the fix/891-nixos-driver-lib branch October 26, 2026 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant