lol
1{ lib
2, stdenv
3, fetchFromGitHub
4, fetchpatch
5, addOpenGLRunpath
6, cudatoolkit
7, pkg-config
8, sha256
9}:
10
11stdenv.mkDerivation rec {
12 pname = "cuda-samples";
13 version = lib.versions.majorMinor cudatoolkit.version;
14
15 src = fetchFromGitHub {
16 owner = "NVIDIA";
17 repo = pname;
18 rev = "v${version}";
19 inherit sha256;
20 };
21
22 nativeBuildInputs = [ pkg-config addOpenGLRunpath ];
23
24 buildInputs = [ cudatoolkit ];
25
26 # See https://github.com/NVIDIA/cuda-samples/issues/75.
27 patches = lib.optionals (version == "11.3") [
28 (fetchpatch {
29 url = "https://github.com/NVIDIA/cuda-samples/commit/5c3ec60faeb7a3c4ad9372c99114d7bb922fda8d.patch";
30 sha256 = "sha256-0XxdmNK9MPpHwv8+qECJTvXGlFxc+fIbta4ynYprfpU=";
31 })
32 ];
33
34 enableParallelBuilding = true;
35
36 preConfigure = ''
37 export CUDA_PATH=${cudatoolkit}
38 '';
39
40 installPhase = ''
41 runHook preInstall
42
43 install -Dm755 -t $out/bin bin/${stdenv.hostPlatform.parsed.cpu.name}/${stdenv.hostPlatform.parsed.kernel.name}/release/*
44
45 runHook postInstall
46 '';
47
48 postFixup = ''
49 for exe in $out/bin/*; do
50 addOpenGLRunpath $exe
51 done
52 '';
53
54 meta = {
55 description = "Samples for CUDA Developers which demonstrates features in CUDA Toolkit";
56 # CUDA itself is proprietary, but these sample apps are not.
57 license = lib.licenses.bsd3;
58 maintainers = with lib.maintainers; [ obsidian-systems-maintenance ];
59 };
60}