{ lib, stdenv, fetchFromGitHub, rocmUpdateScript, cmake, pkg-config, libdrm, python, wrapPython, autoPatchelfHook, }: let esmi_ib_src = fetchFromGitHub { owner = "amd"; repo = "esmi_ib_library"; rev = "esmi_pkg_ver-4.2"; hash = "sha256-czF9ezkAO0PuDkXh8y639AcOZH+KVcWiXPX74H5W/nw="; }; in stdenv.mkDerivation (finalAttrs: { pname = "amdsmi"; version = "7.2.3"; src = fetchFromGitHub { owner = "ROCm"; repo = "rocm-systems"; rev = "rocm-${finalAttrs.version}"; sparseCheckout = [ "projects/amdsmi" "shared" ]; hash = "sha256-TFi+3txemvV6K827e8S3hZOd9jcj4Qzop6V9CdKrpLg="; }; sourceRoot = "${finalAttrs.src.name}/projects/amdsmi"; postPatch = '' substituteInPlace goamdsmi_shim/CMakeLists.txt \ --replace-fail "amd_smi)" ${"'"}''${AMD_SMI_TARGET})' \ --replace-fail 'target_link_libraries(''${GOAMDSMI_SHIM_TARGET} -L' '#' substituteInPlace CMakeLists.txt \ --replace-fail "if(NOT latest_esmi_tag STREQUAL current_esmi_tag)" "if(OFF)" # Manually unpack esmi_ib_src and add amd_hsmp.h so execute-process git clone doesn't run cp -rf --no-preserve=mode ${esmi_ib_src} ./esmi_ib_library mkdir -p ./esmi_ib_library/include/asm cp ./include/amd_smi/impl/amd_hsmp.h ./esmi_ib_library/include/asm/amd_hsmp.h ''; patches = [ # Fix error: redefinition of 'struct drm_color_ctm_3x4' # https://github.com/ROCm/amdsmi/pull/165 ./drm-struct-redefinition-fix.patch ]; nativeBuildInputs = [ cmake pkg-config wrapPython autoPatchelfHook ]; buildInputs = [ libdrm ]; cmakeFlags = [ # Manually define CMAKE_INSTALL_