VA-API in Nix applications on non-NixOS

Is it possible to get VA-API working with applications installed via nix on a non-NixOS system? On Ubuntu 20.04, vainfo is unable to find some libraries,

$ nix-shell -p libva-utils -p xorg.libpciaccess -p libdrm --run vainfo
libva info: VA-API version 1.14.0
libva info: Trying to open /run/opengl-driver/lib/dri/iHD_drv_video.so
libva info: Trying to open /usr/lib/dri/iHD_drv_video.so
libva info: Trying to open /usr/lib32/dri/iHD_drv_video.so
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so
libva error: dlopen of /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so failed: libpciaccess.so.0: cannot open shared object file: No such file or directory
libva info: Trying to open /usr/lib/i386-linux-gnu/dri/iHD_drv_video.so
libva info: va_openDriver() returns -1
libva info: Trying to open /run/opengl-driver/lib/dri/i965_drv_video.so
libva info: Trying to open /usr/lib/dri/i965_drv_video.so
libva info: Trying to open /usr/lib32/dri/i965_drv_video.so
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/i965_drv_video.so
libva error: dlopen of /usr/lib/x86_64-linux-gnu/dri/i965_drv_video.so failed: libdrm_intel.so.1: cannot open shared object file: No such file or directory
libva info: Trying to open /usr/lib/i386-linux-gnu/dri/i965_drv_video.so
libva info: va_openDriver() returns -1
vaInitialize failed with error code -1 (unknown libva error),exit

On NixOS, vainfo finds the library file(s) it’s looking for under /run/opengl-driver/lib/dri/, but that of course does not exist on non-NixOS systems. Is there a way to make libva look in under /nix/store/ for the libraries? Or to make Nix maintain /run/opengl-driver/ like it does on NixOS?

LD_LIBRARY_PATH or patchelf --add-rpath the executable directly. Neither solution is great because of abi compatibility.

1 Like

GitHub - nix-community/nixGL: A wrapper tool for nix OpenGL application [maintainer=@guibou] looks relevant, but no idea about va-api specifically.

1 Like

The nixGL wrappers are exactly what I needed. Thanks!