Merge pull request #269475 from jonringer/addhardwarerunpath-mini

addDriverRunpath: init

authored by Atemu and committed by GitHub fd7f5fd9 ab59f0da

+52
+3
nixos/doc/manual/release-notes/rl-2405.section.md
··· 34 34 35 35 <!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. --> 36 36 37 + - `addDriverRunpath` has been added to facilitate the deprecation of the old `addOpenGLRunpath` setuphook. This change is motivated by the evolution of the setuphook to include all hardware acceleration. 38 + 37 39 - Cinnamon has been updated to 6.0. Please beware that the [Wayland session](https://blog.linuxmint.com/?p=4591) is still experimental in this release. 38 40 39 41 - Programs written in [Nim](https://nim-lang.org/) are built with libraries selected by lockfiles. ··· 50 52 - New instances of Gitea using MySQL now ignore the `[database].CHARSET` config option and always use the `utf8mb4` charset, existing instances should migrate via the `gitea doctor convert` CLI command. 51 53 52 54 - The `hardware.pulseaudio` module now sets permission of pulse user home directory to 755 when running in "systemWide" mode. It fixes [issue 114399](https://github.com/NixOS/nixpkgs/issues/114399). 55 +
+14
pkgs/build-support/add-driver-runpath/default.nix
··· 1 + { lib, stdenv }: 2 + 3 + stdenv.mkDerivation { 4 + name = "add-driver-runpath"; 5 + 6 + # Named "opengl-driver" for legacy reasons, but it is the path to 7 + # hardware drivers installed by NixOS 8 + driverLink = "/run/opengl-driver" + lib.optionalString stdenv.isi686 "-32"; 9 + 10 + buildCommand = '' 11 + mkdir -p $out/nix-support 12 + substituteAll ${./setup-hook.sh} $out/nix-support/setup-hook 13 + ''; 14 + }
+29
pkgs/build-support/add-driver-runpath/setup-hook.sh
··· 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. 8 + addDriverRunpath() { 9 + local forceRpath= 10 + 11 + while [ $# -gt 0 ]; do 12 + case "$1" in 13 + --) shift; break;; 14 + --force-rpath) shift; forceRpath=1;; 15 + --*) 16 + echo "addDriverRunpath: ERROR: Invalid command line" \ 17 + "argument: $1" >&2 18 + return 1;; 19 + *) break;; 20 + esac 21 + done 22 + 23 + for file in "$@"; do 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" 27 + done 28 + } 29 +
+6
pkgs/top-level/all-packages.nix
··· 226 226 227 227 chkservice = callPackage ../tools/admin/chkservice { }; 228 228 229 + # addDriverRunpath is the preferred package name, as this enables 230 + # many more scenarios than just opengl now. 231 + addDriverRunpath = callPackage ../build-support/add-driver-runpath { }; 232 + 233 + # addOpenGLRunpath should be added to aliases.nix after the 24.05 branch-off. 234 + # Post 24.11 branch-off, this should throw an error in aliases.nix. 229 235 addOpenGLRunpath = callPackage ../build-support/add-opengl-runpath { }; 230 236 231 237 quickemu = callPackage ../development/quickemu { };