2021-09-08 15:04:31 +02:00
|
|
|
{ lib, stdenv, fetchFromGitHub, writeScript, cmake, wrapPython }:
|
2020-07-17 08:07:09 +02:00
|
|
|
|
2021-03-24 10:04:45 +01:00
|
|
|
stdenv.mkDerivation rec {
|
2020-07-17 08:07:09 +02:00
|
|
|
pname = "rocm-smi";
|
2021-09-02 22:03:18 +02:00
|
|
|
version = "4.3.1";
|
2020-07-17 08:07:09 +02:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "RadeonOpenCompute";
|
2021-03-24 10:04:45 +01:00
|
|
|
repo = "rocm_smi_lib";
|
2020-07-17 08:07:09 +02:00
|
|
|
rev = "rocm-${version}";
|
2021-09-02 22:03:18 +02:00
|
|
|
hash = "sha256-Ckno73Otkc9rHEUkSgNoOui+6ZHGUF+B9iAoe0NQH0c=";
|
2020-07-17 08:07:09 +02:00
|
|
|
};
|
|
|
|
|
2021-09-02 22:03:18 +02:00
|
|
|
nativeBuildInputs = [ cmake wrapPython ];
|
2020-07-17 08:07:09 +02:00
|
|
|
|
2021-03-24 10:04:45 +01:00
|
|
|
postPatch = ''
|
|
|
|
# Upstream ROCm is installed in an /opt directory. For this reason,
|
|
|
|
# it does not completely follow FHS layout, creating top-level
|
|
|
|
# rocm_smi, oam, and bindings top-level directories. Since rocm-smi
|
|
|
|
# is a package that is typically installed, we change the paths to
|
|
|
|
# follow FHS more closely.
|
2020-07-17 08:07:09 +02:00
|
|
|
|
2021-03-24 10:04:45 +01:00
|
|
|
# rocm_smi libraries and headers go into lib and include. Bindings
|
|
|
|
# go into lib/rocm_smi/bindings.
|
|
|
|
substituteInPlace rocm_smi/CMakeLists.txt \
|
|
|
|
--replace "DESTINATION rocm_smi/" "DESTINATION " \
|
|
|
|
--replace "DESTINATION bindings" "DESTINATION lib/rocm_smi/bindings" \
|
|
|
|
--replace "../rocm_smi/bindings/rsmiBindings.py" "../lib/rocm_smi/bindings/rsmiBindings.py" \
|
|
|
|
--replace 'DESTINATION ''${ROCM_SMI}/' "DESTINATION "
|
|
|
|
|
|
|
|
# oam libraries and headers go into lib and include.
|
|
|
|
substituteInPlace oam/CMakeLists.txt \
|
|
|
|
--replace "DESTINATION oam/" "DESTINATION " \
|
|
|
|
--replace 'DESTINATION ''${OAM_NAME}/' "DESTINATION "
|
|
|
|
|
|
|
|
# Update relative path to librocm_smi64 in the Python binding.
|
|
|
|
substituteInPlace python_smi_tools/rsmiBindings.py \
|
|
|
|
--replace "/../lib/librocm_smi64.so" "/../../librocm_smi64.so"
|
|
|
|
'';
|
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
wrapPythonProgramsIn $out/bin
|
2020-07-17 08:07:09 +02:00
|
|
|
'';
|
|
|
|
|
2021-09-08 15:04:31 +02:00
|
|
|
passthru.updateScript = writeScript "update.sh" ''
|
|
|
|
#!/usr/bin/env nix-shell
|
|
|
|
#!nix-shell -i bash -p curl jq common-updater-scripts
|
|
|
|
version="$(curl -sL "https://api.github.com/repos/RadeonOpenCompute/rocm_smi_lib/releases?per_page=1" | jq '.[0].tag_name | split("-") | .[1]' --raw-output)"
|
|
|
|
update-source-version rocm-smi "$version"
|
|
|
|
'';
|
|
|
|
|
2020-07-17 08:07:09 +02:00
|
|
|
meta = with lib; {
|
|
|
|
description = "System management interface for AMD GPUs supported by ROCm";
|
2021-09-08 15:04:31 +02:00
|
|
|
homepage = "https://github.com/RadeonOpenCompute/rocm_smi_lib";
|
2020-07-17 08:07:09 +02:00
|
|
|
license = with licenses; [ mit ];
|
2021-09-02 22:03:18 +02:00
|
|
|
maintainers = with maintainers; [ lovesegfault ];
|
2021-03-24 10:04:45 +01:00
|
|
|
platforms = [ "x86_64-linux" ];
|
2020-07-17 08:07:09 +02:00
|
|
|
};
|
|
|
|
}
|