1 # Set RUNPATH so that driver libraries in /run/opengl-driver(-32)/lib can be found.
2 # This is needed to not rely on LD_LIBRARY_PATH which does not work with setuid
3 # executables. Fixes https://github.com/NixOS/nixpkgs/issues/22760. It must be run
4 # in postFixup because RUNPATH stripping in fixup would undo it. Note that patchelf
5 # actually sets RUNPATH not RPATH, which applies only to dependencies of the binary
6 # it set on (including for dlopen), so the RUNPATH must indeed be set on these
7 # libraries and would not work if set only on executables.
11 while [ $# -gt 0 ]; do
14 --force-rpath) shift; forceRpath
=1;;
16 echo "addDriverRunpath: ERROR: Invalid command line" \
24 if ! isELF
"$file"; then continue; fi
25 local origRpath
="$(patchelf --print-rpath "$file")"
26 patchelf
--set-rpath "@driverLink@/lib:$origRpath" ${forceRpath:+--force-rpath} "$file"