Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ stdenv
2, lib
3, libPath
4, cudatoolkit
5, fetchurl
6, autoPatchelfHook
7, addOpenGLRunpath
8
9, version
10, hash
11}:
12
13let
14 mostOfVersion = builtins.concatStringsSep "."
15 (lib.take 3 (lib.versions.splitVersion version));
16 platform = "${stdenv.hostPlatform.parsed.kernel.name}-${stdenv.hostPlatform.parsed.cpu.name}";
17in
18
19stdenv.mkDerivation {
20 pname = "cudatoolkit-${cudatoolkit.majorVersion}-cutensor";
21 inherit version;
22
23 src = fetchurl {
24 url = if lib.versionOlder mostOfVersion "1.3.3"
25 then "https://developer.download.nvidia.com/compute/cutensor/${mostOfVersion}/local_installers/libcutensor-${platform}-${version}.tar.gz"
26 else "https://developer.download.nvidia.com/compute/cutensor/redist/libcutensor/${platform}/libcutensor-${platform}-${version}-archive.tar.xz";
27 inherit hash;
28 };
29
30 outputs = [ "out" "dev" ];
31
32 nativeBuildInputs = [
33 autoPatchelfHook
34 addOpenGLRunpath
35 ];
36
37 buildInputs = [
38 stdenv.cc.cc.lib
39 ];
40
41 propagatedBuildInputs = [
42 cudatoolkit
43 ];
44
45 # Set RUNPATH so that libcuda in /run/opengl-driver(-32)/lib can be found.
46 # See the explanation in addOpenGLRunpath.
47 installPhase = ''
48 mkdir -p "$out" "$dev"
49 mv include "$dev"
50 mv ${libPath} "$out/lib"
51
52 function finalRPathFixups {
53 for lib in $out/lib/lib*.so; do
54 addOpenGLRunpath $lib
55 done
56 }
57 postFixupHooks+=(finalRPathFixups)
58 '';
59
60 passthru = {
61 inherit cudatoolkit;
62 majorVersion = lib.versions.major version;
63 };
64
65 meta = with lib; {
66 description = "cuTENSOR: A High-Performance CUDA Library For Tensor Primitives";
67 homepage = "https://developer.nvidia.com/cutensor";
68 sourceProvenance = with sourceTypes; [ binaryNativeCode ];
69 license = licenses.unfree;
70 platforms = [ "x86_64-linux" ];
71 maintainers = with maintainers; [ obsidian-systems-maintenance ];
72 };
73}