# Failure to use shell.nix to add OpenGL Libraries

**URL:** https://discourse.nixos.org/t/failure-to-use-shell-nix-to-add-opengl-libraries/51305
**Category:** Help
**Created:** [August 29, 2024, 12:45am UTC](https://discourse.nixos.org/t/failure-to-use-shell-nix-to-add-opengl-libraries/51305 "2024-08-29T00:45:09Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![alphy](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/a/edb3f5/32.png) [@alphy](https://discourse.nixos.org/u/alphy)
#### Post date: [August 29, 2024, 12:45am UTC](https://discourse.nixos.org/t/failure-to-use-shell-nix-to-add-opengl-libraries/51305/1 "2024-08-29T00:45:09Z")

</div>

I’m trying to revive an old project that I’ve neglected. When I first started the project, I installed “sbcl\_2\_0\_2”, “SDL2”, “libGL”, and “libGL\_driver”, and exported LD\_LIBRARY\_PATH=“$env/lib” and LIBGL\_DRIVERS\_PATH=“$env/lib/dri”. At the time, it was on a Debian system, and thus there was no “system” support for this – but I was able to get it to work at the time!

Since then, I have moved to a computer with NixOS installed, but I still want to keep the dependencies “tracked” in a “shell.nix” file; I have updated SBCL to “sbcl\_2\_3\_9”, I cannot get it to find the libraries. When I try to install “libGL\_driver”, I find it’s no longer available, and without it, I get the following errors (using LIBGL\_DEBUG=“verbose”):

```auto
This is SBCL 2.3.9.nixos, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.

SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses. See the CREDITS and COPYING files in the
distribution for more information.
To load "sdl2":
  Load 1 ASDF system:
    sdl2
; Loading "sdl2"
..................
* (load "first-window")
hello, world!

T
* (first-window)
Using SDL2 Library Version: 2.0.20

So far, so good!
libGL: Can't open configuration file /etc/drirc: No such file or directory.
libGL: Can't open configuration file /home/odin/alphy/.drirc: No such file or directory.
libGL: using driver amdgpu for 15
libGL: Can't open configuration file /etc/drirc: No such file or directory.
libGL: Can't open configuration file /home/odin/alphy/.drirc: No such file or directory.
libGL: pci id for fd 15: 1002:1636, driver radeonsi
libGL: MESA-LOADER: failed to open /nix/store/208frkc81rdw5s0jcdp5rfgkiq0mlmf5-hamilton-iv-epsilon-env/lib/dri/radeonsi_dri.so: /nix/store/208frkc81rdw5s0jcdp5rfgkiq0mlmf5-hamilton-iv-epsilon-env/lib/dri/radeonsi_dri.so: cannot open shared object file: No such file or directory
libGL error: MESA-LOADER: failed to open radeonsi: /nix/store/208frkc81rdw5s0jcdp5rfgkiq0mlmf5-hamilton-iv-epsilon-env/lib/dri/radeonsi_dri.so: cannot open shared object file: No such file or directory (search paths /nix/store/208frkc81rdw5s0jcdp5rfgkiq0mlmf5-hamilton-iv-epsilon-env/lib/dri, suffix _dri)
libGL error: failed to load driver: radeonsi
libGL: MESA-LOADER: failed to open /nix/store/208frkc81rdw5s0jcdp5rfgkiq0mlmf5-hamilton-iv-epsilon-env/lib/dri/swrast_dri.so: /nix/store/208frkc81rdw5s0jcdp5rfgkiq0mlmf5-hamilton-iv-epsilon-env/lib/dri/swrast_dri.so: cannot open shared object file: No such file or directory
libGL error: MESA-LOADER: failed to open swrast: /nix/store/208frkc81rdw5s0jcdp5rfgkiq0mlmf5-hamilton-iv-epsilon-env/lib/dri/swrast_dri.so: cannot open shared object file: No such file or directory (search paths /nix/store/208frkc81rdw5s0jcdp5rfgkiq0mlmf5-hamilton-iv-epsilon-env/lib/dri, suffix _dri)
libGL error: failed to load driver: swrast
X Error of failed request: BadValue (integer parameter out of range for operation)
  Major opcode of failed request: 150 (GLX)
  Minor opcode of failed request: 3 (X_GLXCreateContext)
  Value in failed request: 0x0
  Serial number of failed request: 112
  Current serial number in output stream: 113

```

I have seen a tutorial describing how to use “configuration.nix” to install these libraries, but besides the fact that this goes counter to the spirit of “shell.nix”, when I try to use “configuration.nix” to install these libraries, they are unavailable to the shell environment! (As they _should be_, I might add! 😉 )

How do I install these drivers? Ideally, I’d like to install them by “shell.nix”, but if that’s not possible, I may need help understanding how to access the system versions of these drivers from a “shell.nix” shell.

---

<div class="post-metadata">

### Author: ![alphy](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/a/edb3f5/32.png) [@alphy](https://discourse.nixos.org/u/alphy)
#### Post date: [August 29, 2024, 11:43pm UTC](https://discourse.nixos.org/t/failure-to-use-shell-nix-to-add-opengl-libraries/51305/2 "2024-08-29T23:43:32Z")

</div>

Ok, I got it to work!

I was reviewing what I could find (again), and this time, through some trial and error, I found that installing “mesa.driver” instead of “libGL\_driver” is what I needed!

(I also tried installing the “mesa” package, but for whatever reasons I don’t fully understand, that wasn’t sufficient for providing the libraries.)

I cannot help but fear that this is an esoteric problem that only affects me, but if not, I hope this saves someone from some grief!
