summary refs log tree commit diff
path: root/pkgs/development/libraries/vulkan-loader/default.nix
diff options
context:
space:
mode:
authorAmbroz Bizjak <abizjak.pro@gmail.com>2019-05-22 18:30:05 +0200
committerAmbroz Bizjak <abizjak.pro@gmail.com>2019-05-22 18:30:05 +0200
commit1860e506e7f2fd66982929cfb75ec83b0a586acb (patch)
tree3489508dc23bf1aa3fd4ce0111ea20028347fdb3 /pkgs/development/libraries/vulkan-loader/default.nix
parent2874e849d99e4e96154fc2a7ce4b2e5d8ed4e699 (diff)
downloadnixpkgs-1860e506e7f2fd66982929cfb75ec83b0a586acb.tar
nixpkgs-1860e506e7f2fd66982929cfb75ec83b0a586acb.tar.gz
nixpkgs-1860e506e7f2fd66982929cfb75ec83b0a586acb.tar.bz2
nixpkgs-1860e506e7f2fd66982929cfb75ec83b0a586acb.tar.lz
nixpkgs-1860e506e7f2fd66982929cfb75ec83b0a586acb.tar.xz
nixpkgs-1860e506e7f2fd66982929cfb75ec83b0a586acb.tar.zst
nixpkgs-1860e506e7f2fd66982929cfb75ec83b0a586acb.zip
libglvnd, ocl-icd, vulkan-loader: Add driver library paths to RUNPATH.
Previously we were relying on LD_LIBRARY_PATH to discover driver libraries (libGL, ligGLX, libEGL, OpenCL and Vulkan). This has the problem that setuid programs (in particular VirtualBox) ignore LD_LIBRARY_PATH. Fix it by setting RUNPATH in various dispatch libraries.

This is not needed for libvdpau because it is already configured to look for libraries in the driver paths.

Fixes https://github.com/NixOS/nixpkgs/issues/22760.
Diffstat (limited to 'pkgs/development/libraries/vulkan-loader/default.nix')
-rw-r--r--pkgs/development/libraries/vulkan-loader/default.nix12
1 files changed, 9 insertions, 3 deletions
diff --git a/pkgs/development/libraries/vulkan-loader/default.nix b/pkgs/development/libraries/vulkan-loader/default.nix
index 7d53065ba32..891ad373e02 100644
--- a/pkgs/development/libraries/vulkan-loader/default.nix
+++ b/pkgs/development/libraries/vulkan-loader/default.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchFromGitHub, cmake, python3, vulkan-headers, pkgconfig
-, xlibsWrapper, libxcb, libXrandr, libXext, wayland, libGL_driver }:
+, xlibsWrapper, libxcb, libXrandr, libXext, wayland, addOpenGLRunpath }:
 
 let
   version = "1.1.106";
@@ -17,17 +17,23 @@ stdenv.mkDerivation rec {
     sha256 = "0zhrwj1gi90x2w8gaaaw5h4b969a8gfy244kn0drrplhhb1nqz3b";
   };
 
-  nativeBuildInputs = [ pkgconfig ];
+  nativeBuildInputs = [ pkgconfig addOpenGLRunpath ];
   buildInputs = [ cmake python3 xlibsWrapper libxcb libXrandr libXext wayland ];
   enableParallelBuilding = true;
 
   cmakeFlags = [
-    "-DFALLBACK_DATA_DIRS=${libGL_driver.driverLink}/share:/usr/local/share:/usr/share"
+    "-DFALLBACK_DATA_DIRS=${addOpenGLRunpath.driverLink}/share:/usr/local/share:/usr/share"
     "-DVULKAN_HEADERS_INSTALL_DIR=${vulkan-headers}"
   ];
 
   outputs = [ "out" "dev" ];
 
+  # Set RUNPATH so that driver libraries in /run/opengl-driver(-32)/lib can be found.
+  # See the explanation in addOpenGLRunpath.
+  postFixup = ''
+    addOpenGLRunpath $out/lib/libvulkan.so
+  '';
+
   meta = with stdenv.lib; {
     description = "LunarG Vulkan loader";
     homepage    = https://www.lunarg.com;