geekbench4: use autoPatchelfHook and do not hardcode CUDA lib

This commit is contained in:
Thiago Kenji Okada 2023-03-10 20:48:56 +00:00
parent 3a9aec4691
commit 04cdb56ec9

View file

@ -1,4 +1,12 @@
{ lib, stdenv, fetchurl, makeWrapper, ocl-icd, vulkan-loader, linuxPackages }:
{ lib
, stdenv
, fetchurl
, autoPatchelfHook
, addOpenGLRunpath
, makeWrapper
, ocl-icd
, vulkan-loader
}:
stdenv.mkDerivation rec {
pname = "geekbench";
@ -12,23 +20,25 @@ stdenv.mkDerivation rec {
dontConfigure = true;
dontBuild = true;
nativeBuildInputs = [ makeWrapper ];
nativeBuildInputs = [ autoPatchelfHook makeWrapper ];
buildInputs = [ stdenv.cc.cc ];
installPhase = ''
mkdir -p $out/bin $out/lib
runHook preInstall
mkdir -p $out/bin
cp -r geekbench.plar geekbench4 geekbench_x86_64 $out/bin
# needed for compute benchmark
ln -s ${linuxPackages.nvidia_x11}/lib/libcuda.so $out/lib/
ln -s ${ocl-icd}/lib/libOpenCL.so $out/lib/
ln -s ${ocl-icd}/lib/libOpenCL.so.1 $out/lib/
ln -s ${vulkan-loader}/lib/libvulkan.so $out/lib/
ln -s ${vulkan-loader}/lib/libvulkan.so.1 $out/lib/
for f in geekbench4 geekbench_x86_64 ; do
patchelf --set-interpreter $(cat ${stdenv.cc}/nix-support/dynamic-linker) $out/bin/$f
wrapProgram $out/bin/$f --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ stdenv.cc.cc.lib ]}:$out/lib/"
wrapProgram $out/bin/$f \
--prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [
addOpenGLRunpath.driverLink
ocl-icd
vulkan-loader
]}"
done
runHook postInstall
'';
meta = with lib; {