nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 rocmUpdateScript,
6 cmake,
7 pkg-config,
8 amdsmi,
9 rocm-smi,
10 rocm-runtime,
11 libcap,
12 libdrm,
13 grpc,
14 protobuf,
15 openssl,
16 doxygen,
17 graphviz,
18 texliveSmall,
19 gtest,
20 buildDocs ? true,
21 buildTests ? false,
22}:
23
24let
25 latex = lib.optionalAttrs buildDocs (
26 texliveSmall.withPackages (
27 ps: with ps; [
28 changepage
29 latexmk
30 varwidth
31 multirow
32 hanging
33 adjustbox
34 collectbox
35 stackengine
36 enumitem
37 alphalph
38 wasysym
39 sectsty
40 tocloft
41 newunicodechar
42 etoc
43 helvetic
44 wasy
45 courier
46 ]
47 )
48 );
49in
50stdenv.mkDerivation (finalAttrs: {
51 pname = "rdc";
52 version = "7.1.1";
53
54 outputs = [
55 "out"
56 ]
57 ++ lib.optionals buildDocs [
58 "doc"
59 ]
60 ++ lib.optionals buildTests [
61 "test"
62 ];
63
64 src = fetchFromGitHub {
65 owner = "ROCm";
66 repo = "rdc";
67 rev = "rocm-${finalAttrs.version}";
68 hash = "sha256-oJS0fBeISpgjZkaMfFl/Yq7mPOsdaZDqiRjSPv7kT1Q=";
69 };
70
71 patches = [
72 # https://github.com/ROCm/rocm-systems/pull/2423
73 ./fix-cmake-cxxflags.patch
74 # https://github.com/ROCm/rocm-systems/pull/2424
75 ./fix-libcap-pkgconfig.patch
76 ];
77
78 nativeBuildInputs = [
79 cmake
80 pkg-config
81 protobuf
82 ]
83 ++ lib.optionals buildDocs [
84 doxygen
85 graphviz
86 latex
87 ];
88
89 buildInputs = [
90 amdsmi
91 rocm-smi
92 rocm-runtime
93 libcap
94 libdrm
95 grpc
96 openssl
97 ]
98 ++ lib.optionals buildTests [
99 gtest
100 ];
101
102 cmakeFlags = [
103 "-DCMAKE_VERBOSE_MAKEFILE=ON"
104 "-DRDC_INSTALL_PREFIX=${placeholder "out"}"
105 "-DBUILD_RVS=OFF" # TODO: Needs RVS package
106 "-DBUILD_ROCRTEST=ON"
107 "-DRSMI_INC_DIR=${rocm-smi}/include"
108 "-DRSMI_LIB_DIR=${rocm-smi}/lib"
109 "-DGRPC_ROOT=${grpc}"
110 # Manually define CMAKE_INSTALL_<DIR>
111 # See: https://github.com/NixOS/nixpkgs/pull/197838
112 "-DCMAKE_INSTALL_BINDIR=bin"
113 "-DCMAKE_INSTALL_LIBDIR=lib"
114 "-DCMAKE_INSTALL_INCLUDEDIR=include"
115 "-DCMAKE_INSTALL_LIBEXECDIR=libexec"
116 "-DCMAKE_INSTALL_DOCDIR=doc"
117 ]
118 ++ lib.optionals buildTests [
119 "-DBUILD_TESTS=ON"
120 ];
121
122 postPatch = ''
123 substituteInPlace CMakeLists.txt \
124 --replace-fail "file(STRINGS /etc/os-release LINUX_DISTRO LIMIT_COUNT 1 REGEX \"NAME=\")" "set(LINUX_DISTRO \"NixOS\")"
125 '';
126
127 postInstall = ''
128 find $out/bin -executable -type f -exec \
129 patchelf {} --shrink-rpath --allowed-rpath-prefixes "$NIX_STORE" \;
130 ''
131 + lib.optionalString buildTests ''
132 mkdir -p $test
133 mv $out/bin/rdctst_tests $test/bin
134 '';
135
136 passthru.updateScript = rocmUpdateScript {
137 name = finalAttrs.pname;
138 inherit (finalAttrs.src) owner;
139 inherit (finalAttrs.src) repo;
140 };
141
142 meta = {
143 description = "Simplifies administration and addresses infrastructure challenges in cluster and datacenter environments";
144 homepage = "https://github.com/ROCm/rdc";
145 license = with lib.licenses; [ mit ];
146 teams = [ lib.teams.rocm ];
147 platforms = lib.platforms.linux;
148 };
149})