at master 90 lines 2.3 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchFromGitHub, 5 fetchpatch, 6 rocmUpdateScript, 7 cmake, 8 pkg-config, 9 libdrm, 10 wrapPython, 11 autoPatchelfHook, 12}: 13 14let 15 esmi_ib_src = fetchFromGitHub { 16 owner = "amd"; 17 repo = "esmi_ib_library"; 18 rev = "esmi_pkg_ver-3.0.3"; 19 hash = "sha256-q0w5c5c+CpXkklmSyfzc+sbkt4cHNxscGJA3AXwvHxQ="; 20 }; 21in 22stdenv.mkDerivation (finalAttrs: { 23 pname = "amdsmi"; 24 version = "6.3.3"; 25 src = fetchFromGitHub { 26 owner = "rocm"; 27 repo = "amdsmi"; 28 rev = "rocm-${finalAttrs.version}"; 29 hash = "sha256-hrPqd4ZWqzTG7JRfVwc1SZx6TNS0Q/LFg8yDxrM3mPo="; 30 }; 31 32 postPatch = '' 33 substituteInPlace goamdsmi_shim/CMakeLists.txt \ 34 --replace-fail "amd_smi)" ${"'"}''${AMD_SMI_TARGET})' \ 35 --replace-fail 'target_link_libraries(''${GOAMDSMI_SHIM_TARGET} -L' '#' 36 37 # Manually unpack esmi_ib_src and add amd_hsmp.h so execute-process git clone doesn't run 38 cp -rf --no-preserve=mode ${esmi_ib_src} ./esmi_ib_library 39 mkdir -p ./esmi_ib_library/include/asm 40 cp ./include/amd_smi/impl/amd_hsmp.h ./esmi_ib_library/include/asm/amd_hsmp.h 41 ''; 42 43 patches = [ 44 # Fix ld.lld undefined reference: drmGetVersion 45 (fetchpatch { 46 url = "https://github.com/ROCm/amdsmi/commit/c3864bf6171970d86dc50fd23f06377736823997.patch"; 47 hash = "sha256-zRG1tBD8sIQCWdKfCbXC/Z/6d6NTrRYvRpddPWdM4j8="; 48 }) 49 ]; 50 51 nativeBuildInputs = [ 52 cmake 53 pkg-config 54 wrapPython 55 autoPatchelfHook 56 ]; 57 58 buildInputs = [ 59 libdrm 60 ]; 61 62 cmakeFlags = [ 63 # Manually define CMAKE_INSTALL_<DIR> 64 # See: https://github.com/NixOS/nixpkgs/pull/197838 65 "-DCMAKE_INSTALL_BINDIR=bin" 66 "-DCMAKE_INSTALL_LIBDIR=lib" 67 "-DCMAKE_INSTALL_INCLUDEDIR=include" 68 ]; 69 70 postInstall = '' 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 = with lib; { 83 description = "System management interface for AMD GPUs supported by ROCm"; 84 homepage = "https://github.com/ROCm/rocm_smi_lib"; 85 license = with licenses; [ mit ]; 86 maintainers = with maintainers; [ lovesegfault ]; 87 teams = [ teams.rocm ]; 88 platforms = [ "x86_64-linux" ]; 89 }; 90})