1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 rocmUpdateScript,
6 cmake,
7 rocm-cmake,
8 rocm-runtime,
9 busybox,
10 python3,
11 gnugrep,
12 clr, # Only for localGpuTargets
13 # rocminfo requires that the calling user have a password and be in
14 # the video group. If we let rocm_agent_enumerator rely upon
15 # rocminfo's output, then it, too, has those requirements. Instead,
16 # we can specify the GPU targets for this system (e.g. "gfx803" for
17 # Polaris) such that no system call is needed for downstream
18 # compilers to determine the desired target.
19 defaultTargets ? (clr.localGpuTargets or [ ]),
20}:
21
22stdenv.mkDerivation (finalAttrs: {
23 version = "6.3.3";
24 pname = "rocminfo";
25
26 src = fetchFromGitHub {
27 owner = "ROCm";
28 repo = "rocminfo";
29 rev = "rocm-${finalAttrs.version}";
30 sha256 = "sha256-fQPtO5TNbCbaZZ7VtGkkqng5QZ+FcScdh1opWr5YkLU=";
31 };
32
33 strictDeps = true;
34
35 nativeBuildInputs = [
36 cmake
37 rocm-cmake
38 python3
39 ];
40
41 buildInputs = [ rocm-runtime ];
42 cmakeFlags = [ "-DROCRTST_BLD_TYPE=Release" ];
43
44 prePatch = ''
45 patchShebangs rocm_agent_enumerator
46 sed 's,lsmod | grep ,${busybox}/bin/lsmod | ${gnugrep}/bin/grep ,' -i rocminfo.cc
47 '';
48
49 postInstall = lib.optionalString (defaultTargets != [ ]) ''
50 echo '${lib.concatStringsSep "\n" defaultTargets}' > $out/bin/target.lst
51 '';
52
53 passthru.updateScript = rocmUpdateScript {
54 name = finalAttrs.pname;
55 inherit (finalAttrs.src) owner;
56 inherit (finalAttrs.src) repo;
57 };
58
59 meta = with lib; {
60 description = "ROCm Application for Reporting System Info";
61 homepage = "https://github.com/ROCm/rocminfo";
62 license = licenses.ncsa;
63 mainProgram = "rocminfo";
64 maintainers = with maintainers; [ lovesegfault ];
65 teams = [ teams.rocm ];
66 platforms = platforms.linux;
67 };
68})