Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 autoAddDriverRunpath, 3 backendStdenv, 4 cmake, 5 cudatoolkit, 6 cudaMajorMinorVersion, 7 fetchFromGitHub, 8 fetchpatch, 9 freeimage, 10 glfw3, 11 hash, 12 lib, 13 pkg-config, 14 stdenv, 15}: 16let 17 inherit (lib) lists strings; 18in 19backendStdenv.mkDerivation (finalAttrs: { 20 strictDeps = true; 21 22 pname = "cuda-samples"; 23 version = cudaMajorMinorVersion; 24 25 src = fetchFromGitHub { 26 owner = "NVIDIA"; 27 repo = "cuda-samples"; 28 rev = "v${finalAttrs.version}"; 29 inherit hash; 30 }; 31 32 nativeBuildInputs = [ 33 autoAddDriverRunpath 34 pkg-config 35 ] 36 # CMake has to run as a native, build-time dependency for libNVVM samples. 37 # However, it's not the primary build tool -- that's still make. 38 # As such, we disable CMake's build system. 39 ++ lists.optionals (strings.versionAtLeast finalAttrs.version "12.2") [ cmake ]; 40 41 dontUseCmakeConfigure = true; 42 43 buildInputs = [ 44 cudatoolkit 45 freeimage 46 glfw3 47 ]; 48 49 # See https://github.com/NVIDIA/cuda-samples/issues/75. 50 patches = lib.optionals (finalAttrs.version == "11.3") [ 51 (fetchpatch { 52 url = "https://github.com/NVIDIA/cuda-samples/commit/5c3ec60faeb7a3c4ad9372c99114d7bb922fda8d.patch"; 53 hash = "sha256-0XxdmNK9MPpHwv8+qECJTvXGlFxc+fIbta4ynYprfpU="; 54 }) 55 ]; 56 57 enableParallelBuilding = true; 58 59 preConfigure = '' 60 export CUDA_PATH=${cudatoolkit} 61 ''; 62 63 installPhase = '' 64 runHook preInstall 65 66 install -Dm755 -t $out/bin bin/${stdenv.hostPlatform.parsed.cpu.name}/${stdenv.hostPlatform.parsed.kernel.name}/release/* 67 68 runHook postInstall 69 ''; 70 71 meta = { 72 description = "Samples for CUDA Developers which demonstrates features in CUDA Toolkit"; 73 # CUDA itself is proprietary, but these sample apps are not. 74 license = lib.licenses.bsd3; 75 platforms = [ "x86_64-linux" ]; 76 maintainers = with lib.maintainers; [ obsidian-systems-maintenance ]; 77 teams = [ lib.teams.cuda ]; 78 }; 79})