-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support libGL in non-NixOS Nixpkgs #62169
Comments
Isn't trying to load host libraries recipe for library version conflicts? I rather think we should have an easy way to install the correct driver libraries with nix. |
I think a better solution is to make it so that if the user puts the correct driver in the user profile (e.g. nvidia-x11), the libraries should be found automatically. The implementation would involve some fiddling with dispatch libraries and driver config files (some config files for these things currently specify a library name only). |
libGL should be backwards compatible, so binaries compiled with older version of libGL should still work with newer libGL versions. If the system libGL is older, this could be a problem, which is why we would also need a mesa fallback. This is how everyone outside of Nix world distributes binaries (with
I don't think users should be messing with their libGL installation. It should be provided by the system in the same way the kernel or graphics server are. Also consider cases where we aren't installing anything. For instance, nix-bundle apps will not have a modifiable nix profile that a user can add to. We need a way for Nix closures to just work out of the box without installation. |
@matthewbauer Thanks for opening the issue to discuss. Here's my understanding (echoing some points above):
Am I missing a viable alternative? |
The problem is not really libGL but all the other libraries that the libGL needs. It may expect a specific version of libstdc++, libdrm, etc.. For such libraries (assuming they are even found), either a library from the host system or from nix is going to be loaded first, and when some code from the other "world" needs it it will get the wrong library. I think there is no solution to make this just magically work, without this risk with library versions. One thing that may look like it could work is |
@ambrop72 Beat me to the punch 😄 Yes, it's a frustrating situation. nix-bundle is in the same situation as AppImage IIUC. From the AppImage docs:
But in nix, we want to give people flexibility to use whatever gcc / libc they want. That's a good thing. But the status quo isn't compatible with this. In my fantasy world, I want libGL.so to be built into a separate process, that apps load and communicate with as a subprocess, so there's no version conflicts and you can use what's on your system. But that seems to be outside of the scope of this issue. |
When no libGL drivers are found, we will fall back to “libGLX_mesa.so” which corresponds to the mesa “swrast” driver. This uses some X11 apis for rendering, and is suitable for many use cases of . This is still not as good as having the hardware drivers. Adding libGLX_mesa.so to the closures ends up adding about 1MB, which is signifcant but still acceptable. Fixes NixOS#62032 Fixes NixOS#62169 Fixes NixOS#9415
@ambrop72 I looked into |
I think that the only approach that would really solve the entire issue is to make the dynamic linker work in the following ways when
I think that getting #45105 to work could allow implementing this, possibly even without glibc code changes. The reason is that when libraries are linked by absolute path, they do not satisfy dependencies that are not absolute (not sure about the reverse, I hope that holds too). The libc exception could be implemented by not linking libc with an absolute path but still relying on |
This package consists mostly of command-line tools, but there are also two qt5-based image viewers (`mrview` and `shview`). I have provided an option `withGui = true` to allow users to disable these viewers. They work on NixOS but unlikely to work out-of-the box on non-NixOS Linux (see NixOS#62169), but I've refrained from asserting that they shouldn't be built since a user might want to fiddle with runtime GL stuff. Some programs rely on FSL and/or ANTs backends; I have somewhat heavy-handedly wrapped all binaries to point to ANTs, while FSL is not available in Nix at the moment and has a non-commercial license so would be convenient to disable by default for Hydra builds.
I marked this as stale due to inactivity. → More info |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: |
Issue description
Trying to figure out some solutions for #9415, but wanted to see whether these ideas are workable. Feedback on this is appreciated!
The main goal here is to make libGL work out of the box on Nixpkgs without NixOS installed. This has been an issue for a long time, and could be fixed with adding
LD_LIBRARY_PATH
. I want this to work out of the box, though. I think there are two things we can do to improve this experience:Patch libglvnd to fallback to
__GLX_VENDOR_LIBRARY_NAME=mesa
when no system GL driver is found. This is software-based and slower, but at least it will work in a "pure" way. This could increase closure size, but I think those drivers might already be there.Add
/usr/lib/libGL.so
to the OpenGL RUNPATH. This is the location in almost every Linux distro, so it should be fairly predictable for us to use. This could be a libglvnd wrapped libGL though? This was already done for/run/opengl-driver
in libglvnd, ocl-icd, vulkan-loader: Add /run/opengl-driver(-32) to RUNPATH. #60985. Ideally we could add/usr/lib/libGL.so
without adding/usr/lib/
to avoid adding tons of impurities.Discussed in https://discourse.nixos.org/t/software-rendering-using-mesa-not-possible/3023/8
/cc @ambrop72 @vcunat @edahlgren @abbradar
The text was updated successfully, but these errors were encountered: