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