about summary refs log tree commit diff
path: root/pkgs/development/compilers/cudatoolkit/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/compilers/cudatoolkit/default.nix')
-rw-r--r--pkgs/development/compilers/cudatoolkit/default.nix14
1 files changed, 12 insertions, 2 deletions
diff --git a/pkgs/development/compilers/cudatoolkit/default.nix b/pkgs/development/compilers/cudatoolkit/default.nix
index e2c3c8fe587b..6a18c05f38e5 100644
--- a/pkgs/development/compilers/cudatoolkit/default.nix
+++ b/pkgs/development/compilers/cudatoolkit/default.nix
@@ -1,6 +1,7 @@
 { lib, stdenv, makeWrapper, fetchurl, requireFile, perl, ncurses5, expat, python27, zlib
 , gcc48, gcc49, gcc5, gcc6, gcc7
 , xorg, gtk2, gdk_pixbuf, glib, fontconfig, freetype, unixODBC, alsaLib, glibc
+, addOpenGLRunpath
 }:
 
 let
@@ -39,7 +40,7 @@ let
 
       outputs = [ "out" "lib" "doc" ];
 
-      nativeBuildInputs = [ perl makeWrapper ];
+      nativeBuildInputs = [ perl makeWrapper addOpenGLRunpath ];
       buildInputs = [ gdk_pixbuf ]; # To get $GDK_PIXBUF_MODULE_FILE via setup-hook
       runtimeDependencies = [
         ncurses5 expat python zlib glibc
@@ -143,10 +144,19 @@ let
           else
             rpath2=$rpath:$lib/lib:$out/jre/lib/amd64/jli:$out/lib:$out/lib64:$out/nvvm/lib:$out/nvvm/lib64
           fi
-          patchelf --set-rpath $rpath2 --force-rpath $i
+          patchelf --set-rpath "$rpath2" --force-rpath $i
         done < <(find $out $lib $doc -type f -print0)
       '';
 
+      # Set RPATH so that libcuda and other libraries in
+      # /run/opengl-driver(-32)/lib can be found. See the explanation in
+      # addOpenGLRunpath.  Don't try to figure out which libraries really need
+      # it, just patch all (but not the stubs libraries). Note that
+      # --force-rpath prevents changing RPATH (set above) to RUNPATH.
+      postFixup = ''
+        addOpenGLRunpath --force-rpath {$out,$lib}/lib/lib*.so
+      '';
+
       # cuda-gdb doesn't run correctly when not using sandboxing, so
       # temporarily disabling the install check.  This should be set to true
       # when we figure out how to get `cuda-gdb --version` to run correctly