From 84fcca07aa4f8a9072b717cbacde3dc02dfd7a02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20de=20Kok?= Date: Wed, 24 Mar 2021 10:04:45 +0100 Subject: [PATCH] rocm-smi: 4.0.0 -> 4.1.0 This also migrates this derivation from the old deprecated ROC-smi repository to rocm_smi_lib. --- pkgs/tools/system/rocm-smi/default.nix | 44 +++++++++++++++++++------- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/pkgs/tools/system/rocm-smi/default.nix b/pkgs/tools/system/rocm-smi/default.nix index cd4eef89520..ac980e6c36c 100644 --- a/pkgs/tools/system/rocm-smi/default.nix +++ b/pkgs/tools/system/rocm-smi/default.nix @@ -1,23 +1,45 @@ -{ lib, buildPythonApplication, fetchFromGitHub }: +{ lib, stdenv, fetchFromGitHub, cmake, python3 }: -buildPythonApplication rec { +stdenv.mkDerivation rec { pname = "rocm-smi"; - version = "4.0.0"; + version = "4.1.0"; src = fetchFromGitHub { owner = "RadeonOpenCompute"; - repo = "ROC-smi"; + repo = "rocm_smi_lib"; rev = "rocm-${version}"; - hash = "sha256-0QqaBMkqRVEl89x3hvWQGAgt7LbtMZPhuf7KenQYHaQ="; + hash = "sha256-LEaC1XhmyoVWrpL05MhgN02LVT2rLKdnw9g2QdfM/uE="; }; - format = "other"; + nativeBuildInputs = [ cmake python3.pkgs.wrapPython ]; - dontConfigure = true; - dontBuild = true; + 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. - installPhase = '' - install -Dm0755 rocm_smi.py $out/bin/rocm-smi + # 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 ''; meta = with lib; { @@ -25,6 +47,6 @@ buildPythonApplication rec { homepage = "https://github.com/RadeonOpenCompute/ROC-smi"; license = with licenses; [ mit ]; maintainers = with maintainers; [ danieldk ]; - platforms = platforms.linux; + platforms = [ "x86_64-linux" ]; }; }