Run OpenGL application installed by Nix package manager

nixnixosopenglx11

When I try to run application which uses OpenGL installed or built with Nix package manager, GLX errors shows up:

$ /nix/store/p6fwy23nfcadxr4i780knajvmzga17aa-glxinfo-8.1.0/bin/glxinfo 
libGL error: failed to open drm device: No such file or directory
libGL error: failed to load driver: r600
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast
X Error of failed request:  GLXBadContext
  Major opcode of failed request:  156 (GLX)
  Minor opcode of failed request:  6 (X_GLXIsDirect)
  Serial number of failed request:  50
  Current serial number in output stream:  49

Best Answer

In Nix mesa is patched to search drivers in /run/opengl-driver directory.

Install mesa-noglu:

$ nix-env -i mesa-noglu

and create symlink

$ sudo ln -s /nix/store/*-mesa-noglu-*-drivers /run/opengl-driver