1 Context
I have a private repo that builds via nix
(in case it matters, the repo is a Haskell + Stack project). In particular, this repo has some low-level graphics dependencies, including (at the top level):
buildInputs = with pkgs; [ mesa
xorg.pixman
wayland-protocols
wayland
xorg.libX11
dbus
weston
];
And the system which I'm building this repo on is an Arch Linux machine (with nix
installed outside the package manager).
2 Problem
The program compiles fine, however when I launch it I get the soul-crushing run-time error:
Loading module '/nix/store/98ipsxd20n5nw71q1kjpb5kyr55ysx7y-weston-2.0.0/lib/libweston-2/x11-backend.so'
Loading module '/nix/store/98ipsxd20n5nw71q1kjpb5kyr55ysx7y-weston-2.0.0/lib/libweston-2/gl-renderer.so'
EGL client extensions: EGL_EXT_client_extensions EGL_EXT_platform_base
EGL_KHR_client_get_all_proc_addresses EGL_KHR_debug
EGL_EXT_platform_wayland EGL_EXT_platform_x11
EGL_MESA_platform_gbm
libEGL warning: DRI2: failed to authenticate
libEGL warning: DRI2: failed to open swrast (search paths /run/opengl-driver/lib/dri)
failed to initialize display
EGL error state: EGL_NOT_INITIALIZED (0x3001)
Socket: wayland-0
program-name: user error (Failed compiling shader Shader {shaderID = 0})
3 Inelegant Solution
The issue is that it's searching in /run/opengl-driver/lib/dri
, which is a NixOS specific path. In fact -- when I build and launch this program on my secondary NixOS system, it compiles and runs just fine.
A horrendous hack to fix this issue on non-NixOS systems is to run:
sudo ln -s /nix/store/*-mesa-noglu-*-drivers /run/opengl-driver
Question: Is there a more elegant, Nixish solution to this problem?
Sorry, but that is an open problem at the time of writing.
https://github.com/NixOS/nixpkgs/issues/9415