2022-06-03 03:00:01 +02:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
2021-09-21 09:03:01 +02:00
|
|
|
, fetchFromGitHub
|
|
|
|
, fetchpatch
|
2022-06-03 03:00:01 +02:00
|
|
|
, addOpenGLRunpath
|
|
|
|
, cudatoolkit
|
2021-09-21 09:03:01 +02:00
|
|
|
, pkg-config
|
|
|
|
, sha256
|
2021-03-09 19:04:03 +01:00
|
|
|
}:
|
|
|
|
|
2022-06-03 03:00:01 +02:00
|
|
|
stdenv.mkDerivation rec {
|
2021-03-09 19:04:03 +01:00
|
|
|
pname = "cuda-samples";
|
|
|
|
version = lib.versions.majorMinor cudatoolkit.version;
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "NVIDIA";
|
|
|
|
repo = pname;
|
|
|
|
rev = "v${version}";
|
|
|
|
inherit sha256;
|
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [ pkg-config addOpenGLRunpath ];
|
|
|
|
|
|
|
|
buildInputs = [ cudatoolkit ];
|
|
|
|
|
2021-09-21 09:03:01 +02:00
|
|
|
# See https://github.com/NVIDIA/cuda-samples/issues/75.
|
|
|
|
patches = lib.optionals (version == "11.3") [
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://github.com/NVIDIA/cuda-samples/commit/5c3ec60faeb7a3c4ad9372c99114d7bb922fda8d.patch";
|
2022-06-03 03:00:01 +02:00
|
|
|
sha256 = "sha256-0XxdmNK9MPpHwv8+qECJTvXGlFxc+fIbta4ynYprfpU=";
|
2021-09-21 09:03:01 +02:00
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2021-03-09 19:04:03 +01:00
|
|
|
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;
|
2021-03-17 23:44:46 +01:00
|
|
|
maintainers = with lib.maintainers; [ obsidian-systems-maintenance ];
|
2021-03-09 19:04:03 +01:00
|
|
|
};
|
|
|
|
}
|