summary refs log tree commit diff
path: root/pkgs/test/cuda/cuda-samples/generic.nix
blob: 2e3dcc8891f46bff5a61d60119e91db275eeb4ac (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
{ lib, stdenv, fetchFromGitHub
, pkg-config, addOpenGLRunpath
, sha256, cudatoolkit
}:

let
  pname = "cuda-samples";
  version = lib.versions.majorMinor cudatoolkit.version;
in

stdenv.mkDerivation {
  inherit pname version;

  src = fetchFromGitHub {
    owner = "NVIDIA";
    repo = pname;
    rev = "v${version}";
    inherit sha256;
  };

  nativeBuildInputs = [ pkg-config addOpenGLRunpath ];

  buildInputs = [ cudatoolkit ];

  enableParallelBuilding = true;

  preConfigure = ''
    export CUDA_PATH=${cudatoolkit}
  '';

  installPhase = ''
    runHook preInstall

    install -Dm755 -t $out/bin bin/${stdenv.hostPlatform.parsed.cpu.name}/${stdenv.hostPlatform.parsed.kernel.name}/release/*

    runHook postInstall
  '';

  postFixup = ''
    for exe in $out/bin/*; do
      addOpenGLRunpath $exe
    done
  '';

  meta = {
    description = "Samples for CUDA Developers which demonstrates features in CUDA Toolkit";
    # CUDA itself is proprietary, but these sample apps are not.
    license = lib.licenses.bsd3;
    maintainers = with lib.maintainers; [ obsidian-systems-maintenance ];
  };
}