Skip to content

libGL not working on non-NixOS (without setting up) #9415

Open

Description

@joepie91
  • Package: openarena
  • Error: /nix/store/q8smn7k0y349ymfc9mdnja0wa6s79njv-openarena-0.8.8/openarena-0.8.8/openarena.x86_64: error while loading shared libraries: libGL.so.1: cannot open shared object file: No such file or directory
  • Platform: openSUSE 13.1, x86_64, XFCE
  • Version: nix-env (Nix) 1.9

Installation works, running it does not.

sven@linux-etoq:~> nix-env -i openarena
installing ‘openarena-0.8.8’
these paths will be fetched (390.19 MiB download, 426.80 MiB unpacked):
  /nix/store/q8smn7k0y349ymfc9mdnja0wa6s79njv-openarena-0.8.8
fetching path ‘/nix/store/q8smn7k0y349ymfc9mdnja0wa6s79njv-openarena-0.8.8’...

*** Downloading ‘https://cache.nixos.org/nar/194liswh0vgrj02q7q7ww8igizn45bri6ip4m5wxa47s3ghj65q7.nar.xz’ to ‘/nix/store/q8smn7k0y349ymfc9mdnja0wa6s79njv-openarena-0.8.8’...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  390M  100  390M    0     0  7996k      0  0:00:49  0:00:49 --:--:-- 9247k

building path(s) ‘/nix/store/j0lc0hns2kna9sw1g3k46zbazxhsxha0-user-environment’
sven@linux-etoq:~> openarena 
/nix/store/q8smn7k0y349ymfc9mdnja0wa6s79njv-openarena-0.8.8/openarena-0.8.8/openarena.x86_64: error while loading shared libraries: libGL.so.1: cannot open shared object file: No such file or directory

Activity

  1. bjornfor commented on Aug 24, 2015

    @bjornfor
    Contributor

    Tricky... I wonder if it can be fixed binding openarena to mesa libGL. Then you'd at least have something that runs, although not necessarily optimally for your system.

    On NixOS, programs find the selected/best OpenGL implementation here:

    $ echo $LD_LIBRARY_PATH 
    /run/opengl-driver/lib:/run/opengl-driver-32/lib
    

    Something similar can of course be done with nixpkgs programs on non-NixOS (manually set $LD_LIBRARY_PATH).

    CC @vcunat.

  2. vcunat commented on Aug 24, 2015

    @vcunat
    Member

    There's a deliberate choice to be impure in this respect, as I view libGL* as a part of your GPU driver. I expect using your system one is better even for apps that don't report an error (most do link against our version from mesa).

    If one is able, the safest approach on non-nixos should be to actually create /run/opengl-driver/lib (speaking of x86_64-linux) and put symlinks to your system libGL*. Alternatively one could just set $LD_LIBRARY_PATH to the location, but beware if it contains too many other libs...

  3. joepie91 commented on Aug 24, 2015

    @joepie91
    Author

    Hmm. Would this not be a good usecase for parameters (letting you pick between a system libGL* path or a mesa dependency)? Or can those not be specified from the command-line?

    (I'm still pretty new to Nix)

  4. vcunat commented on Aug 24, 2015

    @vcunat
    Member

    You can easily use $LD_LIBRARY_PATH to open any libGL version. I've only seen one person who wanted to use the bundled mesa instead of system libGL (and on NixOS it's often the same one).

  5. domenkozar commented on Sep 4, 2015

    @domenkozar
    Member

    couldn't we require a nixpkgs config setting to be set and wrap all libGL software with it? that way users would get a message how/where to set the setting

  6. vcunat commented on Sep 4, 2015

    @vcunat
    Member

    @domenkozar: I don't understand what you mean. Note that the problems only happen on non-nixos, and different distros have libGL on different locations, I think.

  7. domenkozar commented on Sep 4, 2015

    @domenkozar
    Member

    I'm saying we could use nixpkgs config to set $LD_LIBRARY_PATH for non-nixos users

  8. added
    6.topic: non-nixos
    on Sep 4, 2015
  9. joepie91 commented on Sep 9, 2015

    @joepie91
    Author

    To a non-technical user, what would the correct (current) procedure look like for installing openarena on a non-NixOS distribution? I'm technical, but I don't know much about compiler toolchains, so an ELI5-style explanation might be the best way to make sense of this.

  10. joepie91 commented on Sep 11, 2015

    @joepie91
    Author

    After talking about this with @ttuegel for a while, we've established that the following works:

    1. Install patchelf (nix-env -i patchelf)
    2. Copy the system libGL.so.1 (usually in /usr/lib64) somewhere, eg. ~/.libgl-shim/libGL.so.1.
    3. patchelf --set-rpath /lib:/usr/lib:/lib64:/usr/lib64 ~/.libgl-shim/libGL.so.1 (adjust lib paths if necessary for your distribution)
    4. Replicate other libGL.so.* symlinks that your system has, but in your ~/.libgl-shim, and pointing to your modified copy.
    5. Run openarena as follows: LD_LIBRARY_PATH=~/.libgl-shim openarena

    This approach also seems automatable, and should work for other things that use makeWrapper :)

    I'm still working on something, but once I've gotten further with that, I'll probably do a proper writeup of this on my blog or something.

  11. bjornfor commented on Sep 11, 2015

    @bjornfor
    Contributor

    What does this give beyond what the simpler LD_LIBRARY_PATH=/usr/lib64 openarena provides (substitute for whatever path libGL.so.1 has on your system)? It seems you still need to provide the custom path to libGL, which cannot be automated.

  12. joepie91 commented on Sep 11, 2015

    @joepie91
    Author

    @bjornfor You'd only load the system libGL, and the rest of the dependencies would remain the pure Nix variants.

  13. bjornfor commented on Sep 11, 2015

    @bjornfor
    Contributor

    Good point :-)

  14. bjornfor commented on Sep 12, 2015

    @bjornfor
    Contributor

    What about LD_PRELOAD=/lib/libGL.so.1 openarena then?

  15. 148 remaining items

  16. arximboldi commented on Aug 26, 2024

    @arximboldi
    Contributor

    Uhhhh, skimming through the README and some videos... this looks so interesting! Do you have some idea of how it could be used specifically to solve the libGL problem?

    I am starting to dream of a plausible not so far future where we can use Nix to create portable .appimage for graphical applications... That would be really such a dream...

  17. vcunat commented on Aug 28, 2024

    @vcunat
    Member

    Libcapsule indeed was a promising route attempted years ago. Hopefully it will go better now than back then. I see it got recent commits. 🤞🏽

  18. Pandapip1 commented on Aug 28, 2024

    @Pandapip1
    Member

    I am starting to dream of a plausible not so far future where we can use Nix to create portable .appimage for graphical applications... That would be really such a dream...

    It's funny you should mention that use case. That's literally my use case as well!


    Uhhhh, skimming through the README and some videos... this looks so interesting! Do you have some idea of how it could be used specifically to solve the libGL problem?

    As I understand it, what libcapsule attempts to do is to create a library that at runtime, tries to use the system linker to find the actual libraries and expose them: https://people.collabora.com/~vivek/libcapsule.pdf


    Thus far, I've managed to package libcapsule as well as make a simple builder to make libcapsule-wrapped libraries. The libcapsule derivation seems to be working fine, but something still needs to be fixed with the wrapper. I think I'm now at a point where it makes sense to draft a PR; I'll link that here: #337995

  19. Samueru-sama commented on Sep 7, 2024

    @Samueru-sama

    I am starting to dream of a plausible not so far future where we can use Nix to create portable .appimage for graphical applications... That would be really such a dream...

    We were trying to do that here and just ran into this issue.

  20. georgyo commented on Dec 21, 2024

    @georgyo
    Member

    If you are like me, and just want to replicate what nixos does to create /run/opengl-driver on non-nixos systems then all you need to do is the following. No need to have special environment variables or namespaces.

    For Intel or AMD graphics cards, do the following. There is no need for special AMD drivers any more

    sudo nix-build --out-link /run/opengl-driver  '<nixpkgs>' -A mesa.drivers
    

    For Nvidia, you need to do a little more work, since you need multiple things

    First create opengl-dir.nix

    {
      lib ? import ( <nixpkgs> + /lib),
      pkgs ? import <nixpkgs> {
        config.allowUnfreePredicate =
          pkg:
          builtins.elem (lib.getName pkg) [
            "nvidia-x11"
          ];
      },
      buildEnv ? pkgs.buildEnv,
      mesa ? pkgs.mesa,
      linuxPackages ? pkgs.linuxPackages,
      nvidia-vaapi-driver ? pkgs.nvidia-vaapi-driver
    }:
    
    buildEnv {
      name = "opengl-dir";
      paths = [
        mesa.drivers
        linuxPackages.nvidia_x11.out
        nvidia-vaapi-driver
      ];
    }

    Then link it into place.

    sudo nix-build --out-link /run/opengl-driver opengl-dir.nix
    
  21. Atemu commented on Dec 22, 2024

    @Atemu
    Member

    Note that you will have to do that on every boot and need to refresh it whenever you update your Nixpkgs.

  22. added 2 commits that reference this issue on Apr 6, 2025
  23. arximboldi commented on Apr 22, 2025

    @arximboldi
    Contributor

    @Pandapip1, @Samueru-sama , did any of you manage to get graphical applications bundled as AppImage's using Nix?

  24. Samueru-sama commented on Apr 22, 2025

    @Samueru-sama

    @Pandapip1, @Samueru-sama , did any of you manage to get graphical applications bundled as AppImage's using Nix?

    We gave up and are now using sharun and runimage

  25. exzombie commented on Sep 29, 2025

    @exzombie
    Contributor

    Being quite unhappy with how NixGL causes issues with symbol version conflicts, I made a package that creates /run/opengl-drivers on non-nixos systems. You need to build it using the same nixpkgs that you are using for your packages, which I plan to make easier by providing integration with Home Manager. For now, I'd like to collect some feedback on what you think about this approach. Thanks to @georgyo for the idea!

  26. exzombie commented on Oct 26, 2025

    @exzombie
    Contributor

    As a followup, I have now opened a Home Manager PR. It helps ensure that the drivers at /run/opengl-drivers are kept up to date. I would really appreciate it if HM users have some time to try it out and report if it covers their use cases.

  27. added
    2.status: stale
    on Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    0.kind: bug2.status: stale6.topic: non-nixos

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions