nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 91 lines 2.4 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchFromGitHub, 5 rocmUpdateScript, 6 cmake, 7 pkg-config, 8 libdrm, 9 wrapPython, 10 autoPatchelfHook, 11}: 12 13let 14 esmi_ib_src = fetchFromGitHub { 15 owner = "amd"; 16 repo = "esmi_ib_library"; 17 rev = "esmi_pkg_ver-4.2"; 18 hash = "sha256-czF9ezkAO0PuDkXh8y639AcOZH+KVcWiXPX74H5W/nw="; 19 }; 20in 21stdenv.mkDerivation (finalAttrs: { 22 pname = "amdsmi"; 23 version = "7.1.1"; 24 src = fetchFromGitHub { 25 owner = "rocm"; 26 repo = "amdsmi"; 27 rev = "rocm-${finalAttrs.version}"; 28 hash = "sha256-BGe3+8YFwu41ZVAF+VtN5Cn9pfzGxmCg/Rpq8qWOEoM="; 29 }; 30 31 postPatch = '' 32 substituteInPlace goamdsmi_shim/CMakeLists.txt \ 33 --replace-fail "amd_smi)" ${"'"}''${AMD_SMI_TARGET})' \ 34 --replace-fail 'target_link_libraries(''${GOAMDSMI_SHIM_TARGET} -L' '#' 35 substituteInPlace CMakeLists.txt \ 36 --replace-fail "if(NOT latest_esmi_tag STREQUAL current_esmi_tag)" "if(OFF)" 37 38 # Manually unpack esmi_ib_src and add amd_hsmp.h so execute-process git clone doesn't run 39 cp -rf --no-preserve=mode ${esmi_ib_src} ./esmi_ib_library 40 mkdir -p ./esmi_ib_library/include/asm 41 cp ./include/amd_smi/impl/amd_hsmp.h ./esmi_ib_library/include/asm/amd_hsmp.h 42 ''; 43 44 patches = [ 45 # Fix error: redefinition of 'struct drm_color_ctm_3x4' 46 # https://github.com/ROCm/amdsmi/pull/165 47 ./drm-struct-redefinition-fix.patch 48 ]; 49 50 nativeBuildInputs = [ 51 cmake 52 pkg-config 53 wrapPython 54 autoPatchelfHook 55 ]; 56 57 buildInputs = [ 58 libdrm 59 ]; 60 61 cmakeFlags = [ 62 # Manually define CMAKE_INSTALL_<DIR> 63 # See: https://github.com/NixOS/nixpkgs/pull/197838 64 "-DCMAKE_INSTALL_BINDIR=bin" 65 "-DCMAKE_INSTALL_LIBDIR=lib" 66 "-DCMAKE_INSTALL_INCLUDEDIR=include" 67 ]; 68 69 postInstall = '' 70 makeWrapperArgs=(--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ libdrm ]}) 71 wrapPythonProgramsIn $out 72 rm $out/bin/amd-smi 73 ln -sf $out/libexec/amdsmi_cli/amdsmi_cli.py $out/bin/amd-smi 74 ''; 75 76 passthru.updateScript = rocmUpdateScript { 77 name = finalAttrs.pname; 78 inherit (finalAttrs.src) owner; 79 inherit (finalAttrs.src) repo; 80 }; 81 82 meta = { 83 description = "System management interface for AMD GPUs supported by ROCm"; 84 homepage = "https://github.com/ROCm/rocm_smi_lib"; 85 license = with lib.licenses; [ mit ]; 86 maintainers = with lib.maintainers; [ lovesegfault ]; 87 teams = [ lib.teams.rocm ]; 88 platforms = [ "x86_64-linux" ]; 89 mainProgram = "amd-smi"; 90 }; 91})