Fix alacritty for ubuntu

main
Brian Picciano 4 months ago
parent 11bd1d5d87
commit 570561ac73
  1. 36
      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 \

Loading…
Cancel
Save