Add driver library path to some packages to find CUDA libraries.

This is to avoid relying on LD_LIBRARY_PATH for finding the CUDA driver libraries.
This commit is contained in:
Ambroz Bizjak
2019-05-22 18:34:09 +02:00
parent 1860e506e7
commit 28a0918916
4 changed files with 39 additions and 6 deletions
@@ -7,6 +7,7 @@
, lib
, cudatoolkit
, fetchurl
, addOpenGLRunpath
}:
stdenv.mkDerivation rec {
@@ -19,6 +20,8 @@ stdenv.mkDerivation rec {
inherit sha256;
};
nativeBuildInputs = [ addOpenGLRunpath ];
installPhase = ''
function fixRunPath {
p=$(patchelf --print-rpath $1)
@@ -31,6 +34,12 @@ stdenv.mkDerivation rec {
cp -a lib64 $out/lib64
'';
# Set RUNPATH so that libcuda in /run/opengl-driver(-32)/lib can be found.
# See the explanation in addOpenGLRunpath.
postFixup = ''
addOpenGLRunpath $out/lib/lib*.so
'';
propagatedBuildInputs = [
cudatoolkit
];