nixGL
nixGL copied to clipboard
[feature request] `source $(nixGL shell)` support
It would be super handy to be able to "install" nixGL into a shell session such that I don't have to worry about wrapping each command in nixGL foo ....
Would maintainers be supportive of including such a feature?
You can alias nix-shell to nixGL nixVulkanIntel nix-shell
That's certainly an option, but what I'm ideally looking for is a solution to "install" nixGL in the currently running shell instead of spawning a new one.
That's certainly an option, but what I'm ideally looking for is a solution to "install" nixGL in the currently running shell instead of spawning a new one.
Lately Arch updated its gcc version and now that alias fails with these errors:
nix-shell: /nix/store/bn7pnigb0f8874m6riiw6dngsmdyic1g-gcc-13.3.0-lib/lib/libstdc++.so.6: version `CXXABI_1.3.15' not found (required by /usr/lib/libnixexpr.so)
nix-shell: /nix/store/bn7pnigb0f8874m6riiw6dngsmdyic1g-gcc-13.3.0-lib/lib/libstdc++.so.6: version `CXXABI_1.3.15' not found (required by /usr/lib/libnixmain.so)
nix-shell: /nix/store/bn7pnigb0f8874m6riiw6dngsmdyic1g-gcc-13.3.0-lib/lib/libstdc++.so.6: version `CXXABI_1.3.15' not found (required by /usr/lib/libnixstore.so)
nix-shell: /nix/store/bn7pnigb0f8874m6riiw6dngsmdyic1g-gcc-13.3.0-lib/lib/libstdc++.so.6: version `CXXABI_1.3.15' not found (required by /usr/lib/libnixutil.so)
So, I came up with a more "install" solution:
if [[ ! "$IN_NIX_SHELL" = "" ]] && [[ "$IN_NIXGL" = "" ]]; then
export IN_NIXGL=1
source <(
diff <(env) <(nixGL nixVulkanIntel env) \
| grep '>' | sed 's/^>/export/g'
)
fi
It extracts the environment variables that nixGL and nixVulkanIntel set, and adds them to the current shell.
Was looking at the solutions posted before and after, and in cross-repositories, but decided to make it the "NixOS" way, so that I won't boil my mind
Since I'm running an immutable setup, I wanted to keep the "packaging" unhingeness for personal reasons
The thing: https://github.com/immutarch/postcopy_beta/blob/main/usr/bin/ima-nix-mesa-binder
What this does?
- Runs
nixGL env, checks forLIBGL_LIBRARY_PATHentries, where usually both 64-bit and 32-but MESA outputs are located - Determines which arch are they, and appropiately symlinks each store to
/run/opengl-driver(-32)
Cons:
- You might have to manually re-add symlinks after each mesa + nixgl update
Other than that, it works very much fine with everything graphically-required installed
- Determines which arch are they, and appropiately symlinks each store to
/run/opengl-driver(-32)
I can't understand how the games manage to find the OpenGL drivers in that path. Are you exporting the /run/opengl-driver path?
Are you exporting the /run/opengl-driver path?
No, I am not. The base library preload directory is defined by package on it's own, so this entire thing is almost 1:1 with NixOS in terms of how drivers get loaded
Great. I will check it. Is there any related documentation to that? I want to understand whether something like this is possible for Vulkan.
Great. I will check it. Is there any related documentation to that? I want to understand whether something like this is possible for Vulkan.
No reason to, these directories already include Vulkan drivers and their ICD loaders
Sorry. My fault. I expected Vulkan to require a different method, as it's exposed with nixVulkanIntel, and not nixGL. Your script seems to work fine on Arch.
#!/bin/bash
mkdir -p /etc/tmpfiles.d
get_dri_info(){
MESA_DRIVERS_PATH=$(nixGL env | grep LIBGL_DRIVERS_PATH | cut -d '=' -f 2 | sed 's/\/lib\/dri//g' | sed 's/:/ /g')
for driver in ${MESA_DRIVERS_PATH}
do
DRIVER_FILE=$(file ${driver}/lib/libEGL_mesa.so.0.0.0 | cut -d ' ' -f 3)
if [[ "${DRIVER_FILE}" == "64-bit" ]]; then
DRIVER_64BIT=${driver}
else
DRIVER_32BIT=${driver}
fi
done
echo "64-bit driver path: ${DRIVER_64BIT} | This will be symlinked to /run/opengl-driver"
echo "L+ /run/opengl-driver - - - - ${DRIVER_64BIT}" > /etc/tmpfiles.d/99-nix-ogl-64b.conf
echo "32-bit driver path: ${DRIVER_32BIT} | This will be symlinked to /run/opengl-driver-32"
echo "L+ /run/opengl-driver-32 - - - - ${DRIVER_32BIT}" > /etc/tmpfiles.d/99-nix-ogl-32b.conf
systemd-tmpfiles --create
}
if [[ "$(which nixGL)" ]]; then
get_dri_info
else
echo "nixGL is not installed on this system, please install nixGL"
fi
I've updated my scripts for my distro, so that's why i'm sending an universally working one here
There's now also https://github.com/soupglasses/nix-system-graphics which is an alternative approach to do this with, which utilizes the /run/opengl-driver approach instead of environment variable magic as nixGL does.