nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at devShellTools-shell 97 lines 2.1 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchFromGitHub, 5 rocmUpdateScript, 6 cmake, 7 rocm-cmake, 8 clr, 9 gtest, 10 gbenchmark, 11 buildTests ? false, 12 buildBenchmarks ? false, 13 gpuTargets ? clr.localGpuTargets or [ ], 14}: 15 16stdenv.mkDerivation (finalAttrs: { 17 pname = "rocrand${clr.gpuArchSuffix}"; 18 version = "6.3.3"; 19 20 outputs = [ 21 "out" 22 ] 23 ++ lib.optionals buildTests [ 24 "test" 25 ] 26 ++ lib.optionals buildBenchmarks [ 27 "benchmark" 28 ]; 29 30 src = fetchFromGitHub { 31 owner = "ROCm"; 32 repo = "rocRAND"; 33 rev = "rocm-${finalAttrs.version}"; 34 hash = "sha256-rrRLPqEw39M+6dtPW8DcnQiSZNwxWNINJ1wjU098Vkk="; 35 }; 36 37 nativeBuildInputs = [ 38 cmake 39 rocm-cmake 40 clr 41 ]; 42 43 buildInputs = 44 lib.optionals buildTests [ 45 gtest 46 ] 47 ++ lib.optionals buildBenchmarks [ 48 gbenchmark 49 ]; 50 51 cmakeFlags = [ 52 "-DHIP_ROOT_DIR=${clr}" 53 # Manually define CMAKE_INSTALL_<DIR> 54 # See: https://github.com/NixOS/nixpkgs/pull/197838 55 "-DCMAKE_INSTALL_BINDIR=bin" 56 "-DCMAKE_INSTALL_LIBDIR=lib" 57 "-DCMAKE_INSTALL_INCLUDEDIR=include" 58 ] 59 ++ lib.optionals (gpuTargets != [ ]) [ 60 "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}" 61 ] 62 ++ lib.optionals buildTests [ 63 "-DBUILD_TEST=ON" 64 ] 65 ++ lib.optionals buildBenchmarks [ 66 "-DBUILD_BENCHMARK=ON" 67 ]; 68 69 postInstall = 70 lib.optionalString buildTests '' 71 mkdir -p $test/bin 72 mv $out/bin/test_* $test/bin 73 '' 74 + lib.optionalString buildBenchmarks '' 75 mkdir -p $benchmark/bin 76 mv $out/bin/benchmark_* $benchmark/bin 77 '' 78 + lib.optionalString (buildTests || buildBenchmarks) '' 79 rm -r $out/bin/rocRAND 80 # Fail if bin/ isn't actually empty 81 rmdir $out/bin 82 ''; 83 84 passthru.updateScript = rocmUpdateScript { 85 name = finalAttrs.pname; 86 inherit (finalAttrs.src) owner; 87 inherit (finalAttrs.src) repo; 88 }; 89 90 meta = with lib; { 91 description = "Generate pseudo-random and quasi-random numbers"; 92 homepage = "https://github.com/ROCm/rocRAND"; 93 license = with licenses; [ mit ]; 94 teams = [ teams.rocm ]; 95 platforms = platforms.linux; 96 }; 97})