diff options
Diffstat (limited to 'alacritty')
-rw-r--r-- | alacritty/default.nix | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/alacritty/default.nix b/alacritty/default.nix index 0a84229..b24d696 100644 --- a/alacritty/default.nix +++ b/alacritty/default.nix @@ -19,6 +19,8 @@ alacrittyUnwrap = pkgs.writeShellScript "alacritty-unwrap" '' unset LD_LIBRARY_PATH + unset LIBGL_DRIVERS_PATH + unset LIBVA_DRIVERS_PATH unset __EGL_VENDOR_LIBRARY_DIRS exec "$@" ''; @@ -49,10 +51,36 @@ ''; alacritty = pkgs.writeShellScriptBin "alacritty" '' - # TODO this might break things, especially if the machine is not using - # nvidia, but more investigation is needed. But it at least lets us get rid - # of nixGL. - export LD_LIBRARY_PATH=/usr/lib + set -e -x + + host_ld_lib_path="$( + ldconfig -v 2>/dev/null \ + | grep -v ^$'\t' \ + | tr -s ':\n' ':' \ + | head -c-1 \ + )" + + bin_ld_lib_path="$( + objdump -x ${pkgs.alacritty}/bin/alacritty \ + | grep "RUNPATH" \ + | awk '{print $2}' \ + )" + + host_dri_path="$( + echo "$host_ld_lib_path" \ + | tr -s ':' '\n' \ + | while read d; do if [ -d "$d/dri" ]; then echo "$d"/dri; fi; done \ + | tr '\n' ':' \ + | head -c-1 + )" + + # overwrite LD_LIBRARY_PATH such that the binary's ld search path is still + # searched first, but afterwards the host's ld search path is looked + # through. Similarly, the dri paths are set to be the hosts. This allows us + # to use the host's graphics drivers for alacritty. + export LD_LIBRARY_PATH="$bin_ld_lib_path":"$host_ld_lib_path" + export LIBGL_DRIVERS_PATH="$host_dri_path" + export LIBVA_DRIVERS_PATH="$host_dri_path" export __EGL_VENDOR_LIBRARY_DIRS=/usr/share/glvnd/egl_vendor.d exec ${pkgs.alacritty}/bin/alacritty \ |