2024-01-02 11:29:13 +00:00
|
|
|
{
|
2024-04-21 15:54:59 +00:00
|
|
|
autoAddDriverRunpath,
|
2024-01-02 11:29:13 +00:00
|
|
|
backendStdenv,
|
|
|
|
cmake,
|
|
|
|
cudatoolkit,
|
|
|
|
cudaVersion,
|
|
|
|
fetchFromGitHub,
|
|
|
|
fetchpatch,
|
|
|
|
freeimage,
|
|
|
|
glfw3,
|
|
|
|
hash,
|
|
|
|
lib,
|
|
|
|
pkg-config,
|
2024-04-21 15:54:59 +00:00
|
|
|
stdenv,
|
2021-03-19 17:17:44 +00:00
|
|
|
}:
|
2024-01-02 11:29:13 +00:00
|
|
|
let
|
|
|
|
inherit (lib) lists strings;
|
|
|
|
in
|
2024-04-21 15:54:59 +00:00
|
|
|
backendStdenv.mkDerivation (finalAttrs: {
|
|
|
|
strictDeps = true;
|
2021-03-19 17:17:44 +00:00
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
pname = "cuda-samples";
|
|
|
|
version = cudaVersion;
|
2021-03-19 17:17:44 +00:00
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "NVIDIA";
|
2024-07-27 06:49:29 +00:00
|
|
|
repo = "cuda-samples";
|
2024-04-21 15:54:59 +00:00
|
|
|
rev = "v${finalAttrs.version}";
|
|
|
|
inherit hash;
|
|
|
|
};
|
2023-11-16 04:20:00 +00:00
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
nativeBuildInputs =
|
|
|
|
[
|
|
|
|
autoAddDriverRunpath
|
|
|
|
pkg-config
|
|
|
|
]
|
|
|
|
# CMake has to run as a native, build-time dependency for libNVVM samples.
|
|
|
|
# However, it's not the primary build tool -- that's still make.
|
|
|
|
# As such, we disable CMake's build system.
|
|
|
|
++ lists.optionals (strings.versionAtLeast finalAttrs.version "12.2") [ cmake ];
|
2021-03-19 17:17:44 +00:00
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
dontUseCmakeConfigure = true;
|
2021-03-19 17:17:44 +00:00
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
buildInputs = [
|
|
|
|
cudatoolkit
|
|
|
|
freeimage
|
|
|
|
glfw3
|
|
|
|
];
|
2021-09-26 12:46:18 +00:00
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
# See https://github.com/NVIDIA/cuda-samples/issues/75.
|
|
|
|
patches = lib.optionals (finalAttrs.version == "11.3") [
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://github.com/NVIDIA/cuda-samples/commit/5c3ec60faeb7a3c4ad9372c99114d7bb922fda8d.patch";
|
|
|
|
hash = "sha256-0XxdmNK9MPpHwv8+qECJTvXGlFxc+fIbta4ynYprfpU=";
|
|
|
|
})
|
|
|
|
];
|
2021-03-19 17:17:44 +00:00
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
enableParallelBuilding = true;
|
2021-03-19 17:17:44 +00:00
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
preConfigure = ''
|
|
|
|
export CUDA_PATH=${cudatoolkit}
|
|
|
|
'';
|
2021-03-19 17:17:44 +00:00
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
2021-03-19 17:17:44 +00:00
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
install -Dm755 -t $out/bin bin/${stdenv.hostPlatform.parsed.cpu.name}/${stdenv.hostPlatform.parsed.kernel.name}/release/*
|
2021-03-19 17:17:44 +00:00
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
runHook postInstall
|
|
|
|
'';
|
2024-01-02 11:29:13 +00:00
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
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 ] ++ lib.teams.cuda.members;
|
|
|
|
};
|
|
|
|
})
|