nixpkgs/pkgs/development/libraries/ocl-icd/default.nix
Ambroz Bizjak 1860e506e7 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.
2019-05-22 18:30:05 +02:00

33 lines
950 B
Nix

{stdenv, fetchurl, ruby, opencl-headers, addOpenGLRunpath }:
stdenv.mkDerivation rec {
name = "ocl-icd-${version}";
version = "2.2.10";
src = fetchurl {
url = "https://forge.imag.fr/frs/download.php/810/${name}.tar.gz";
sha256 = "0f14gpa13sdm0kzqv5yycp4pschbmi6n5fj7wl4ilspzsrqcgqr2";
};
nativeBuildInputs = [ ruby addOpenGLRunpath ];
buildInputs = [ opencl-headers ];
postPatch = ''
sed -i 's,"/etc/OpenCL/vendors","${addOpenGLRunpath.driverLink}/etc/OpenCL/vendors",g' ocl_icd_loader.c
'';
# Set RUNPATH so that driver libraries in /run/opengl-driver(-32)/lib can be found.
# See the explanation in addOpenGLRunpath.
postFixup = ''
addOpenGLRunpath $out/lib/libOpenCL.so
'';
meta = with stdenv.lib; {
description = "OpenCL ICD Loader for ${opencl-headers.name}";
homepage = https://forge.imag.fr/projects/ocl-icd/;
license = licenses.bsd2;
platforms = platforms.linux;
};
}