at 15.09-beta 2.4 kB view raw
1{ lib, stdenv, fetchurl, patchelf, perl, ncurses, expat, python, zlib 2, xlibs, gtk2, glib, fontconfig, freetype, unixODBC, alsaLib, glibc 3# generic inputs 4, version, sha256, url ? null, ... 5} : 6 7let 8 # eg, 5.5.22 => 5_5 9 mkShort = let str = stdenv.lib.strings; 10 take = stdenv.lib.lists.take; 11 in v: str.concatStringsSep "_" (take 2 (str.splitString "." v)); 12 shortVer = mkShort version; 13in stdenv.mkDerivation rec { 14 name = "cudatoolkit-${version}"; 15 16 dontPatchELF = true; 17 dontStrip = true; 18 19 src = 20 if stdenv.system == "x86_64-linux" then 21 fetchurl { 22 url = if url != null then url else "http://developer.download.nvidia.com/compute/cuda/${shortVer}/rel/installers/cuda_${version}_linux_64.run"; 23 sha256 = sha256; 24 } 25 else throw "cudatoolkit does not support platform ${stdenv.system}"; 26 27 outputs = [ "out" "sdk" ]; 28 29 buildInputs = [ perl ]; 30 31 runtimeDependencies = [ 32 ncurses expat python zlib glibc 33 xlibs.libX11 xlibs.libXext xlibs.libXrender xlibs.libXt xlibs.libXtst xlibs.libXi xlibs.libXext 34 gtk2 glib fontconfig freetype unixODBC alsaLib 35 ]; 36 37 rpath = "${stdenv.lib.makeLibraryPath runtimeDependencies}:${stdenv.cc.cc}/lib64"; 38 39 unpackPhase = '' 40 sh $src --keep --noexec 41 cd pkg/run_files 42 sh cuda-linux64-rel-${version}-*.run --keep --noexec 43 sh cuda-samples-linux-${version}-*.run --keep --noexec 44 cd pkg 45 ''; 46 47 buildPhase = '' 48 find . -type f -executable -exec patchelf \ 49 --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ 50 '{}' \; || true 51 find . -type f -exec patchelf \ 52 --set-rpath $rpath:$out/jre/lib/amd64/jli:$out/lib:$out/lib64:$out/nvvm/lib:$out/nvvm/lib64:$(cat $NIX_CC/nix-support/orig-cc)/lib \ 53 --force-rpath \ 54 '{}' \; || true 55 ''; 56 57 installPhase = '' 58 mkdir $out $sdk 59 perl ./install-linux.pl --prefix="$out" 60 rm $out/tools/CUDA_Occupancy_Calculator.xls 61 perl ./install-sdk-linux.pl --prefix="$sdk" --cudaprefix="$out" 62 mv $out/include $out/usr_include 63 64 # let's remove the 32-bit libraries, they confuse the lib64->lib mover 65 rm -rf $out/lib 66 67 # Fixup path to samples (needed for cuda 6.5 or else nsight will not find them) 68 if [ -d "$out"/cuda-samples ]; then 69 mv "$out"/cuda-samples "$out"/samples 70 fi 71 ''; 72 73 setupHook = ./setup-hook.sh; 74 75 meta = { 76 license = lib.licenses.unfree; 77 }; 78}