about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/rocm-modules/5
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/rocm-modules/5')
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/clang-ocl/default.nix42
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/clr/default.nix168
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/clr/test-opencl-example.nix75
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/clr/test-rocm-smi.nix23
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/composable_kernel/default.nix88
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/default.nix528
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/half/default.nix39
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/hip-common/default.nix44
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/hipblas/default.nix99
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/hipcc/default.nix46
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/hipcub/default.nix90
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/hipfft/default.nix110
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/hipfort/default.nix66
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/hipify/default.nix50
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/hipsolver/default.nix100
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/hipsparse/default.nix136
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/hsa-amd-aqlprofile-bin/default.nix45
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/llvm/base.nix167
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/llvm/default.nix57
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-1/clang-unwrapped.nix46
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-1/lld.nix13
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-1/llvm.nix10
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-1/runtimes.nix30
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-2/1000-libcxx-failing-tests.list171
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-2/bintools-unwrapped.nix28
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-2/compiler-rt.nix63
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-2/libc.nix26
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-2/libcxx.nix42
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-2/libcxxabi.nix37
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-2/libunwind.nix26
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-2/rstdenv.nix35
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-3/0000-mlir-fix-debugtranslation.patch36
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-3/1000-openmp-failing-tests.list122
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-3/1001-mlir-failing-tests.list11
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-3/clang-tools-extra.nix42
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-3/clang.nix73
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-3/flang.nix31
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-3/libclc.nix36
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-3/lldb.nix39
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-3/mlir.nix57
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-3/openmp.nix54
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-3/polly.nix18
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-3/pstl.nix15
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/migraphx/default.nix172
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/miopen/default.nix240
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/miopengemm/default.nix126
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/mivisionx/default.nix145
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/rccl/default.nix91
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/rdc/default.nix126
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/rocalution/default.nix115
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/rocblas/default.nix209
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/rocdbgapi/default.nix112
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/rocfft/default.nix169
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/rocgdb/default.nix58
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/rocm-cmake/default.nix37
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/rocm-comgr/default.nix55
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/rocm-core/default.nix36
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/rocm-device-libs/cmake.patch43
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/rocm-device-libs/default.nix50
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/rocm-docs-core/default.nix65
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/rocm-runtime/default.nix78
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/rocm-smi/cmake.patch89
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/rocm-smi/default.nix54
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/rocm-thunk/default.nix54
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/rocminfo/default.nix63
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/rocmlir/default.nix130
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/rocprim/default.nix86
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/rocprofiler/default.nix108
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/rocr-debug-agent/default.nix59
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/rocrand/default.nix88
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/rocsolver/default.nix100
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/rocsparse/default.nix149
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/rocsparse/deps.nix222
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/rocthrust/default.nix87
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/roctracer/default.nix105
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/rocwmma/0000-dont-fetch-googletest.patch35
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/rocwmma/default.nix105
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/rpp/default.nix88
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/tensile/default.nix65
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/5/update.nix32
80 files changed, 6680 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/clang-ocl/default.nix b/nixpkgs/pkgs/development/rocm-modules/5/clang-ocl/default.nix
new file mode 100644
index 000000000000..96fc4945747f
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/clang-ocl/default.nix
@@ -0,0 +1,42 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, rocmUpdateScript
+, cmake
+, rocm-cmake
+, rocm-device-libs
+}:
+
+stdenv.mkDerivation (finalAttrs: {
+  pname = "clang-ocl";
+  version = "5.7.0";
+
+  src = fetchFromGitHub {
+    owner = "RadeonOpenCompute";
+    repo = "clang-ocl";
+    rev = "rocm-${finalAttrs.version}";
+    hash = "sha256-uMSvcVJj+me2E+7FsXZ4l4hTcK6uKEegXpkHGcuist0=";
+  };
+
+  nativeBuildInputs = [
+    cmake
+    rocm-cmake
+  ];
+
+  buildInputs = [ rocm-device-libs ];
+
+  passthru.updateScript = rocmUpdateScript {
+    name = finalAttrs.pname;
+    owner = finalAttrs.src.owner;
+    repo = finalAttrs.src.repo;
+  };
+
+  meta = with lib; {
+    description = "OpenCL compilation with clang compiler";
+    homepage = "https://github.com/RadeonOpenCompute/clang-ocl";
+    license = with licenses; [ mit ];
+    maintainers = teams.rocm.members;
+    platforms = platforms.linux;
+    broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
+  };
+})
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/clr/default.nix b/nixpkgs/pkgs/development/rocm-modules/5/clr/default.nix
new file mode 100644
index 000000000000..8a5d695e2b4c
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/clr/default.nix
@@ -0,0 +1,168 @@
+{ lib
+, stdenv
+, callPackage
+, fetchFromGitHub
+, rocmUpdateScript
+, makeWrapper
+, cmake
+, perl
+, clang
+, hip-common
+, hipcc
+, rocm-device-libs
+, rocm-comgr
+, rocm-runtime
+, roctracer
+, rocminfo
+, rocm-smi
+, numactl
+, libGL
+, libxml2
+, libX11
+, python3Packages
+}:
+
+let
+  wrapperArgs = [
+    "--prefix PATH : $out/bin"
+    "--prefix LD_LIBRARY_PATH : ${rocm-runtime}"
+    "--set HIP_PLATFORM amd"
+    "--set HIP_PATH $out"
+    "--set HIP_CLANG_PATH ${clang}/bin"
+    "--set DEVICE_LIB_PATH ${rocm-device-libs}/amdgcn/bitcode"
+    "--set HSA_PATH ${rocm-runtime}"
+    "--set ROCM_PATH $out"
+  ];
+in stdenv.mkDerivation (finalAttrs: {
+  pname = "clr";
+  version = "5.7.0";
+
+  outputs = [
+    "out"
+    "icd"
+  ];
+
+  src = fetchFromGitHub {
+    owner = "ROCm-Developer-Tools";
+    repo = "clr";
+    rev = "rocm-${finalAttrs.version}";
+    hash = "sha256-C+rFW/7kf35rz0sQTI2+iY5RhZZQY07fc5a+e6cB5OQ=";
+  };
+
+  nativeBuildInputs = [
+    makeWrapper
+    cmake
+    perl
+    python3Packages.python
+    python3Packages.cppheaderparser
+  ];
+
+  buildInputs = [
+    numactl
+    libGL
+    libxml2
+    libX11
+  ];
+
+  propagatedBuildInputs = [
+    rocm-device-libs
+    rocm-comgr
+    rocm-runtime
+    rocminfo
+  ];
+
+  cmakeFlags = [
+    "-DCMAKE_POLICY_DEFAULT_CMP0072=NEW" # Prefer newer OpenGL libraries
+    "-DCLR_BUILD_HIP=ON"
+    "-DCLR_BUILD_OCL=ON"
+    "-DHIP_COMMON_DIR=${hip-common}"
+    "-DHIPCC_BIN_DIR=${hipcc}/bin"
+    "-DHIP_PLATFORM=amd"
+    "-DPROF_API_HEADER_PATH=${roctracer.src}/inc/ext"
+    "-DROCM_PATH=${rocminfo}"
+
+    # Temporarily set variables to work around upstream CMakeLists issue
+    # Can be removed once https://github.com/ROCm-Developer-Tools/hipamd/issues/55 is fixed
+    "-DCMAKE_INSTALL_BINDIR=bin"
+    "-DCMAKE_INSTALL_INCLUDEDIR=include"
+    "-DCMAKE_INSTALL_LIBDIR=lib"
+  ];
+
+  postPatch = ''
+    patchShebangs hipamd/src
+
+    # We're not on Windows so these are never installed to hipcc...
+    substituteInPlace hipamd/CMakeLists.txt \
+      --replace "install(PROGRAMS \''${HIPCC_BIN_DIR}/hipcc.bat DESTINATION bin)" "" \
+      --replace "install(PROGRAMS \''${HIPCC_BIN_DIR}/hipconfig.bat DESTINATION bin)" ""
+
+    substituteInPlace hipamd/src/hip_embed_pch.sh \
+      --replace "\''$LLVM_DIR/bin/clang" "${clang}/bin/clang"
+  '';
+
+  postInstall = ''
+    patchShebangs $out/bin
+
+    # hipcc.bin and hipconfig.bin is mysteriously never installed
+    cp -a ${hipcc}/bin/{hipcc.bin,hipconfig.bin} $out/bin
+
+    wrapProgram $out/bin/hipcc.bin ${lib.concatStringsSep " " wrapperArgs}
+    wrapProgram $out/bin/hipconfig.bin ${lib.concatStringsSep " " wrapperArgs}
+    wrapProgram $out/bin/hipcc.pl ${lib.concatStringsSep " " wrapperArgs}
+    wrapProgram $out/bin/hipconfig.pl ${lib.concatStringsSep " " wrapperArgs}
+
+    # Just link rocminfo, it's easier
+    ln -s ${rocminfo}/bin/* $out/bin
+
+    # Replace rocm-opencl-icd functionality
+    mkdir -p $icd/etc/OpenCL/vendors
+    echo "$out/lib/libamdocl64.so" > $icd/etc/OpenCL/vendors/amdocl64.icd
+  '';
+
+  passthru = {
+    # All known and valid general GPU targets
+    # We cannot use this for each ROCm library, as each defines their own supported targets
+    # See: https://github.com/RadeonOpenCompute/ROCm/blob/77cbac4abab13046ee93d8b5bf410684caf91145/README.md#library-target-matrix
+    gpuTargets = lib.forEach [
+      "803"
+      "900"
+      "906"
+      "908"
+      "90a"
+      "940"
+      "941"
+      "942"
+      "1010"
+      "1012"
+      "1030"
+      "1100"
+      "1101"
+      "1102"
+    ] (target: "gfx${target}");
+
+    updateScript = rocmUpdateScript {
+      name = finalAttrs.pname;
+      owner = finalAttrs.src.owner;
+      repo = finalAttrs.src.repo;
+    };
+
+    impureTests = {
+      rocm-smi = callPackage ./test-rocm-smi.nix {
+        inherit rocm-smi;
+        clr = finalAttrs.finalPackage;
+      };
+      opencl-example = callPackage ./test-opencl-example.nix {
+        clr = finalAttrs.finalPackage;
+      };
+    };
+  };
+
+  meta = with lib; {
+    description = "AMD Common Language Runtime for hipamd, opencl, and rocclr";
+    homepage = "https://github.com/ROCm-Developer-Tools/clr";
+    license = with licenses; [ mit ];
+    maintainers = with maintainers; [ lovesegfault ] ++ teams.rocm.members;
+    platforms = platforms.linux;
+    broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
+  };
+})
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/clr/test-opencl-example.nix b/nixpkgs/pkgs/development/rocm-modules/5/clr/test-opencl-example.nix
new file mode 100644
index 000000000000..d6714c6b7d63
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/clr/test-opencl-example.nix
@@ -0,0 +1,75 @@
+{ lib
+, stdenv
+, makeImpureTest
+, fetchFromGitHub
+, clr
+, cmake
+, pkg-config
+, glew
+, freeglut
+, opencl-headers
+, ocl-icd
+}:
+
+let
+
+  examples = stdenv.mkDerivation {
+    pname = "amd-app-samples";
+    version = "2018-06-10";
+
+    src = fetchFromGitHub {
+      owner = "OpenCL";
+      repo = "AMD_APP_samples";
+      rev = "54da6ca465634e78fc51fc25edf5840467ee2411";
+      hash = "sha256-qARQpUiYsamHbko/I1gPZE9pUGJ+3396Vk2n7ERSftA=";
+    };
+
+    nativeBuildInputs = [ cmake pkg-config ];
+
+    buildInputs = [ glew freeglut opencl-headers ocl-icd ];
+
+    installPhase = ''
+      runHook preInstall
+
+      mkdir -p $out/bin
+      # Example path is bin/x86_64/Release/cl/Reduction/Reduction
+      cp -r bin/*/*/*/*/* $out/bin/
+
+      runHook postInstall
+    '';
+
+    cmakeFlags = [ "-DBUILD_CPP_CL=OFF" ];
+
+    meta = with lib; {
+      description = "Samples from the AMD APP SDK (with OpenCRun support) ";
+      homepage    = "https://github.com/OpenCL/AMD_APP_samples";
+      license     = licenses.bsd2;
+      platforms   = platforms.linux;
+      maintainers = lib.teams.rocm.members;
+    };
+  };
+
+in
+makeImpureTest {
+  name = "opencl-example";
+  testedPackage = "rocmPackages_5.clr";
+
+  sandboxPaths = [ "/sys" "/dev/dri" "/dev/kfd" ];
+
+  nativeBuildInputs = [ examples ];
+
+  OCL_ICD_VENDORS = "${clr.icd}/etc/OpenCL/vendors";
+
+  testScript = ''
+    # Examples load resources from current directory
+    cd ${examples}/bin
+    echo OCL_ICD_VENDORS=$OCL_ICD_VENDORS
+    pwd
+
+    HelloWorld | grep HelloWorld
+  '';
+
+  meta = with lib; {
+    maintainers = teams.rocm.members;
+  };
+}
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/clr/test-rocm-smi.nix b/nixpkgs/pkgs/development/rocm-modules/5/clr/test-rocm-smi.nix
new file mode 100644
index 000000000000..25c0a7e0c32c
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/clr/test-rocm-smi.nix
@@ -0,0 +1,23 @@
+{ lib
+, makeImpureTest
+, clinfo
+, clr
+, rocm-smi
+}:
+
+makeImpureTest {
+  name = "rocm-smi";
+  testedPackage = "rocmPackages_5.clr";
+  nativeBuildInputs = [ clinfo rocm-smi ];
+  OCL_ICD_VENDORS = "${clr.icd}/etc/OpenCL/vendors";
+
+  testScript = ''
+    # Test fails if the number of platforms is 0
+    clinfo | grep -E 'Number of platforms * [1-9]'
+    rocm-smi | grep -A1 GPU
+  '';
+
+  meta = with lib; {
+    maintainers = teams.rocm.members;
+  };
+}
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/composable_kernel/default.nix b/nixpkgs/pkgs/development/rocm-modules/5/composable_kernel/default.nix
new file mode 100644
index 000000000000..2372b27ebe52
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/composable_kernel/default.nix
@@ -0,0 +1,88 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, rocmUpdateScript
+, cmake
+, rocm-cmake
+, clr
+, openmp
+, clang-tools-extra
+, gtest
+, buildTests ? false
+, buildExamples ? false
+, gpuTargets ? [ ] # gpuTargets = [ "gfx803" "gfx900" "gfx1030" ... ]
+}:
+
+stdenv.mkDerivation (finalAttrs: {
+  pname = "composable_kernel";
+  version = "5.7.0";
+
+  outputs = [
+    "out"
+  ] ++ lib.optionals buildTests [
+    "test"
+  ] ++ lib.optionals buildExamples [
+    "example"
+  ];
+
+  src = fetchFromGitHub {
+    owner = "ROCmSoftwarePlatform";
+    repo = "composable_kernel";
+    rev = "rocm-${finalAttrs.version}";
+    hash = "sha256-Z9X+S2SijGJ8bhr9ghkkWicBUzLzs9fxPpqZxX6BBM4=";
+  };
+
+  nativeBuildInputs = [
+    cmake
+    rocm-cmake
+    clr
+    clang-tools-extra
+  ];
+
+  buildInputs = [ openmp ];
+
+  cmakeFlags = [
+    "-DCMAKE_C_COMPILER=hipcc"
+    "-DCMAKE_CXX_COMPILER=hipcc"
+  ] ++ lib.optionals (gpuTargets != [ ]) [
+    "-DGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}"
+    "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}"
+  ] ++ lib.optionals buildTests [
+    "-DGOOGLETEST_DIR=${gtest.src}" # Custom linker names
+  ];
+
+  # No flags to build selectively it seems...
+  postPatch = lib.optionalString (!buildTests) ''
+    substituteInPlace CMakeLists.txt \
+      --replace "add_subdirectory(test)" ""
+  '' + lib.optionalString (!buildExamples) ''
+    substituteInPlace CMakeLists.txt \
+      --replace "add_subdirectory(example)" ""
+  '';
+
+  postInstall = lib.optionalString buildTests ''
+    mkdir -p $test/bin
+    mv $out/bin/test_* $test/bin
+  '' + lib.optionalString buildExamples ''
+    mkdir -p $example/bin
+    mv $out/bin/example_* $example/bin
+  '';
+
+  passthru.updateScript = rocmUpdateScript {
+    name = finalAttrs.pname;
+    owner = finalAttrs.src.owner;
+    repo = finalAttrs.src.repo;
+  };
+
+  # Times out otherwise
+  requiredSystemFeatures = [ "big-parallel" ];
+
+  meta = with lib; {
+    description = "Performance portable programming model for machine learning tensor operators";
+    homepage = "https://github.com/ROCmSoftwarePlatform/composable_kernel";
+    license = with licenses; [ mit ];
+    maintainers = teams.rocm.members;
+    platforms = platforms.linux;
+    broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
+  };
+})
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/default.nix b/nixpkgs/pkgs/development/rocm-modules/5/default.nix
new file mode 100644
index 000000000000..6e263998dbe6
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/default.nix
@@ -0,0 +1,528 @@
+{ callPackage
+, recurseIntoAttrs
+, symlinkJoin
+, fetchFromGitHub
+, cudaPackages
+, python3Packages
+, elfutils
+, boost179
+, opencv
+, ffmpeg_4
+, libjpeg_turbo
+, rapidjson-unstable
+}:
+
+let
+  rocmUpdateScript = callPackage ./update.nix { };
+in rec {
+  ## RadeonOpenCompute ##
+  llvm = recurseIntoAttrs (callPackage ./llvm/default.nix { inherit rocmUpdateScript rocm-device-libs rocm-runtime rocm-thunk clr; });
+
+  rocm-core = callPackage ./rocm-core {
+    inherit rocmUpdateScript;
+    stdenv = llvm.rocmClangStdenv;
+  };
+
+  rocm-cmake = callPackage ./rocm-cmake {
+    inherit rocmUpdateScript;
+    stdenv = llvm.rocmClangStdenv;
+  };
+
+  rocm-thunk = callPackage ./rocm-thunk {
+    inherit rocmUpdateScript;
+    stdenv = llvm.rocmClangStdenv;
+  };
+
+  rocm-smi = python3Packages.callPackage ./rocm-smi {
+    inherit rocmUpdateScript;
+    stdenv = llvm.rocmClangStdenv;
+  };
+
+  # Eventually will be in the LLVM repo
+  rocm-device-libs = callPackage ./rocm-device-libs {
+    inherit rocmUpdateScript rocm-cmake;
+    stdenv = llvm.rocmClangStdenv;
+  };
+
+  rocm-runtime = callPackage ./rocm-runtime {
+    inherit rocmUpdateScript rocm-device-libs rocm-thunk;
+    stdenv = llvm.rocmClangStdenv;
+  };
+
+  # Eventually will be in the LLVM repo
+  rocm-comgr = callPackage ./rocm-comgr {
+    inherit rocmUpdateScript rocm-cmake rocm-device-libs;
+    stdenv = llvm.rocmClangStdenv;
+  };
+
+  rocminfo = callPackage ./rocminfo {
+    inherit rocmUpdateScript rocm-cmake rocm-runtime;
+    stdenv = llvm.rocmClangStdenv;
+  };
+
+  clang-ocl = callPackage ./clang-ocl {
+    inherit rocmUpdateScript rocm-cmake rocm-device-libs;
+    stdenv = llvm.rocmClangStdenv;
+  };
+
+  # Unfree
+  hsa-amd-aqlprofile-bin = callPackage ./hsa-amd-aqlprofile-bin {
+    stdenv = llvm.rocmClangStdenv;
+  };
+
+  # Broken, too many errors
+  rdc = callPackage ./rdc {
+    inherit rocmUpdateScript rocm-smi rocm-runtime;
+    # stdenv = llvm.rocmClangStdenv;
+  };
+
+  rocm-docs-core = python3Packages.callPackage ./rocm-docs-core { };
+
+  ## ROCm-Developer-Tools ##
+  hip-common = callPackage ./hip-common {
+    inherit rocmUpdateScript;
+    stdenv = llvm.rocmClangStdenv;
+  };
+
+  # Eventually will be in the LLVM repo
+  hipcc = callPackage ./hipcc {
+    inherit rocmUpdateScript;
+    stdenv = llvm.rocmClangStdenv;
+  };
+
+  # Replaces hip, opencl-runtime, and rocclr
+  clr = callPackage ./clr {
+    inherit rocmUpdateScript hip-common hipcc rocm-device-libs rocm-comgr rocm-runtime roctracer rocminfo rocm-smi;
+    inherit (llvm) clang;
+    stdenv = llvm.rocmClangStdenv;
+  };
+
+  hipify = callPackage ./hipify {
+    inherit rocmUpdateScript;
+    inherit (llvm) clang;
+    stdenv = llvm.rocmClangStdenv;
+  };
+
+  # Needs GCC
+  rocprofiler = callPackage ./rocprofiler {
+    inherit (llvm) clang;
+    inherit rocmUpdateScript clr rocm-thunk roctracer rocm-smi hsa-amd-aqlprofile-bin;
+  };
+
+  # Needs GCC
+  roctracer = callPackage ./roctracer {
+    inherit rocmUpdateScript rocm-device-libs rocm-runtime rocprofiler clr;
+    inherit (llvm) clang;
+  };
+
+  # Needs GCC
+  rocgdb = callPackage ./rocgdb {
+    inherit rocmUpdateScript;
+    elfutils = elfutils.override { enableDebuginfod = true; };
+  };
+
+  rocdbgapi = callPackage ./rocdbgapi {
+    inherit rocmUpdateScript rocm-cmake rocm-comgr rocm-runtime;
+    stdenv = llvm.rocmClangStdenv;
+  };
+
+  rocr-debug-agent = callPackage ./rocr-debug-agent {
+    inherit rocmUpdateScript clr rocdbgapi;
+    stdenv = llvm.rocmClangStdenv;
+  };
+
+  ## ROCmSoftwarePlatform ##
+  rocprim = callPackage ./rocprim {
+    inherit rocmUpdateScript rocm-cmake clr;
+    stdenv = llvm.rocmClangStdenv;
+  };
+
+  rocsparse = callPackage ./rocsparse {
+    inherit rocmUpdateScript rocm-cmake rocprim clr;
+    stdenv = llvm.rocmClangStdenv;
+  };
+
+  rocthrust = callPackage ./rocthrust {
+    inherit rocmUpdateScript rocm-cmake rocprim clr;
+    stdenv = llvm.rocmClangStdenv;
+  };
+
+  rocrand = callPackage ./rocrand {
+    inherit rocmUpdateScript rocm-cmake clr;
+    stdenv = llvm.rocmClangStdenv;
+  };
+
+  hiprand = rocrand; # rocrand includes hiprand
+
+  rocfft = callPackage ./rocfft {
+    inherit rocmUpdateScript rocm-cmake rocrand rocfft clr;
+    inherit (llvm) openmp;
+    stdenv = llvm.rocmClangStdenv;
+  };
+
+  rccl = callPackage ./rccl {
+    inherit rocmUpdateScript rocm-cmake rocm-smi clr hipify;
+    stdenv = llvm.rocmClangStdenv;
+  };
+
+  hipcub = callPackage ./hipcub {
+    inherit rocmUpdateScript rocm-cmake rocprim clr;
+    stdenv = llvm.rocmClangStdenv;
+  };
+
+  hipsparse = callPackage ./hipsparse {
+    inherit rocmUpdateScript rocm-cmake rocsparse clr;
+    inherit (llvm) openmp;
+    stdenv = llvm.rocmClangStdenv;
+  };
+
+  hipfort = callPackage ./hipfort {
+    inherit rocmUpdateScript rocm-cmake;
+    stdenv = llvm.rocmClangStdenv;
+  };
+
+  hipfft = callPackage ./hipfft {
+    inherit rocmUpdateScript rocm-cmake rocfft clr;
+    inherit (llvm) openmp;
+    stdenv = llvm.rocmClangStdenv;
+  };
+
+  tensile = python3Packages.callPackage ./tensile {
+    inherit rocmUpdateScript rocminfo;
+    stdenv = llvm.rocmClangStdenv;
+  };
+
+  rocblas = callPackage ./rocblas {
+    inherit rocblas rocmUpdateScript rocm-cmake clr tensile;
+    inherit (llvm) openmp;
+    stdenv = llvm.rocmClangStdenv;
+  };
+
+  rocsolver = callPackage ./rocsolver {
+    inherit rocmUpdateScript rocm-cmake rocblas rocsparse clr;
+    stdenv = llvm.rocmClangStdenv;
+  };
+
+  rocwmma = callPackage ./rocwmma {
+    inherit rocmUpdateScript rocm-cmake rocm-smi rocblas clr;
+    inherit (llvm) openmp;
+    stdenv = llvm.rocmClangStdenv;
+  };
+
+  rocalution = callPackage ./rocalution {
+    inherit rocmUpdateScript rocm-cmake rocprim rocsparse rocrand rocblas clr;
+    inherit (llvm) openmp;
+    stdenv = llvm.rocmClangStdenv;
+  };
+
+  rocmlir = callPackage ./rocmlir {
+    inherit rocmUpdateScript rocm-cmake clr;
+    stdenv = llvm.rocmClangStdenv;
+  };
+
+  rocmlir-rock = rocmlir.override {
+    buildRockCompiler = true;
+  };
+
+  hipsolver = callPackage ./hipsolver {
+    inherit rocmUpdateScript rocm-cmake rocblas rocsolver clr;
+    stdenv = llvm.rocmClangStdenv;
+  };
+
+  hipblas = callPackage ./hipblas {
+    inherit rocmUpdateScript rocm-cmake rocblas rocsolver clr;
+    stdenv = llvm.rocmClangStdenv;
+  };
+
+  # hipBlasLt - Very broken with Tensile at the moment, only supports GFX9
+  # hipTensor - Only supports GFX9
+
+  miopengemm = callPackage ./miopengemm {
+    inherit rocmUpdateScript rocm-cmake clr;
+    stdenv = llvm.rocmClangStdenv;
+  };
+
+  composable_kernel = callPackage ./composable_kernel {
+    inherit rocmUpdateScript rocm-cmake clr;
+    inherit (llvm) openmp clang-tools-extra;
+    stdenv = llvm.rocmClangStdenv;
+  };
+
+  half = callPackage ./half {
+    inherit rocmUpdateScript rocm-cmake;
+    stdenv = llvm.rocmClangStdenv;
+  };
+
+  miopen = callPackage ./miopen {
+    inherit rocmUpdateScript rocm-cmake rocblas clang-ocl miopengemm composable_kernel rocm-comgr clr rocm-docs-core half;
+    inherit (llvm) clang-tools-extra;
+    stdenv = llvm.rocmClangStdenv;
+    rocmlir = rocmlir-rock;
+    boost = boost179.override { enableStatic = true; };
+  };
+
+  miopen-hip = miopen.override {
+    useOpenCL = false;
+  };
+
+  miopen-opencl = miopen.override {
+    useOpenCL = true;
+  };
+
+  migraphx = callPackage ./migraphx {
+    inherit rocmUpdateScript rocm-cmake rocblas composable_kernel miopengemm miopen clr half rocm-device-libs;
+    inherit (llvm) openmp clang-tools-extra;
+    stdenv = llvm.rocmClangStdenv;
+    rocmlir = rocmlir-rock;
+  };
+
+  ## GPUOpen-ProfessionalCompute-Libraries ##
+  rpp = callPackage ./rpp {
+    inherit rocmUpdateScript rocm-cmake rocm-docs-core clr half;
+    inherit (llvm) openmp;
+    stdenv = llvm.rocmClangStdenv;
+  };
+
+  rpp-hip = rpp.override {
+    useOpenCL = false;
+    useCPU = false;
+  };
+
+  rpp-opencl = rpp.override {
+    useOpenCL = true;
+    useCPU = false;
+  };
+
+  rpp-cpu = rpp.override {
+    useOpenCL = false;
+    useCPU = true;
+  };
+
+  mivisionx = callPackage ./mivisionx {
+    inherit rocmUpdateScript rocm-cmake rocm-device-libs clr rpp rocblas miopengemm miopen migraphx half rocm-docs-core;
+    inherit (llvm) clang openmp;
+    opencv = opencv.override { enablePython = true; };
+    ffmpeg = ffmpeg_4;
+    rapidjson = rapidjson-unstable;
+    stdenv = llvm.rocmClangStdenv;
+
+    # Unfortunately, rocAL needs a custom libjpeg-turbo until further notice
+    # See: https://github.com/GPUOpen-ProfessionalCompute-Libraries/MIVisionX/issues/1051
+    libjpeg_turbo = libjpeg_turbo.overrideAttrs {
+      version = "2.0.6.1";
+
+      src = fetchFromGitHub {
+        owner = "rrawther";
+        repo = "libjpeg-turbo";
+        rev = "640d7ee1917fcd3b6a5271aa6cf4576bccc7c5fb";
+        sha256 = "sha256-T52whJ7nZi8jerJaZtYInC2YDN0QM+9tUDqiNr6IsNY=";
+      };
+    };
+  };
+
+  mivisionx-hip = mivisionx.override {
+    rpp = rpp-hip;
+    useOpenCL = false;
+    useCPU = false;
+  };
+
+  mivisionx-opencl = mivisionx.override {
+    rpp = rpp-opencl;
+    miopen = miopen-opencl;
+    useOpenCL = true;
+    useCPU = false;
+  };
+
+  mivisionx-cpu = mivisionx.override {
+    rpp = rpp-cpu;
+    useOpenCL = false;
+    useCPU = true;
+  };
+
+  ## Meta ##
+  # Emulate common ROCm meta layout
+  # These are mainly for users. I strongly suggest NOT using these in nixpkgs derivations
+  # Don't put these into `propagatedBuildInputs` unless you want PATH/PYTHONPATH issues!
+  # See: https://rocm.docs.amd.com/en/latest/_images/image.004.png
+  # See: https://rocm.docs.amd.com/en/latest/deploy/linux/os-native/package_manager_integration.html
+  meta = rec {
+    rocm-developer-tools = symlinkJoin {
+      name = "rocm-developer-tools-meta";
+
+      paths = [
+        hsa-amd-aqlprofile-bin
+        rocm-core
+        rocr-debug-agent
+        roctracer
+        rocdbgapi
+        rocprofiler
+        rocgdb
+        rocm-language-runtime
+      ];
+    };
+
+    rocm-ml-sdk = symlinkJoin {
+      name = "rocm-ml-sdk-meta";
+
+      paths = [
+        rocm-core
+        miopen-hip
+        rocm-hip-sdk
+        rocm-ml-libraries
+      ];
+    };
+
+    rocm-ml-libraries = symlinkJoin {
+      name = "rocm-ml-libraries-meta";
+
+      paths = [
+        llvm.clang
+        llvm.mlir
+        llvm.openmp
+        rocm-core
+        miopen-hip
+        rocm-hip-libraries
+      ];
+    };
+
+    rocm-hip-sdk = symlinkJoin {
+      name = "rocm-hip-sdk-meta";
+
+      paths = [
+        rocprim
+        rocalution
+        hipfft
+        rocm-core
+        hipcub
+        hipblas
+        rocrand
+        rocfft
+        rocsparse
+        rccl
+        rocthrust
+        rocblas
+        hipsparse
+        hipfort
+        rocwmma
+        hipsolver
+        rocsolver
+        rocm-hip-libraries
+        rocm-hip-runtime-devel
+      ];
+    };
+
+    rocm-hip-libraries = symlinkJoin {
+      name = "rocm-hip-libraries-meta";
+
+      paths = [
+        rocblas
+        hipfort
+        rocm-core
+        rocsolver
+        rocalution
+        rocrand
+        hipblas
+        rocfft
+        hipfft
+        rccl
+        rocsparse
+        hipsparse
+        hipsolver
+        rocm-hip-runtime
+      ];
+    };
+
+    rocm-openmp-sdk = symlinkJoin {
+      name = "rocm-openmp-sdk-meta";
+
+      paths = [
+        rocm-core
+        llvm.clang
+        llvm.mlir
+        llvm.openmp # openmp-extras-devel (https://github.com/ROCm-Developer-Tools/aomp)
+        rocm-language-runtime
+      ];
+    };
+
+    rocm-opencl-sdk = symlinkJoin {
+      name = "rocm-opencl-sdk-meta";
+
+      paths = [
+        rocm-core
+        rocm-runtime
+        clr
+        clr.icd
+        rocm-thunk
+        rocm-opencl-runtime
+      ];
+    };
+
+    rocm-opencl-runtime = symlinkJoin {
+      name = "rocm-opencl-runtime-meta";
+
+      paths = [
+        rocm-core
+        clr
+        clr.icd
+        rocm-language-runtime
+      ];
+    };
+
+    rocm-hip-runtime-devel = symlinkJoin {
+      name = "rocm-hip-runtime-devel-meta";
+
+      paths = [
+        clr
+        rocm-core
+        hipify
+        rocm-cmake
+        llvm.clang
+        llvm.mlir
+        llvm.openmp
+        rocm-thunk
+        rocm-runtime
+        rocm-hip-runtime
+      ];
+    };
+
+    rocm-hip-runtime = symlinkJoin {
+      name = "rocm-hip-runtime-meta";
+
+      paths = [
+        rocm-core
+        rocminfo
+        clr
+        rocm-language-runtime
+      ];
+    };
+
+    rocm-language-runtime = symlinkJoin {
+      name = "rocm-language-runtime-meta";
+
+      paths = [
+        rocm-runtime
+        rocm-core
+        rocm-comgr
+        llvm.openmp # openmp-extras-runtime (https://github.com/ROCm-Developer-Tools/aomp)
+      ];
+    };
+
+    rocm-all = symlinkJoin {
+      name = "rocm-all-meta";
+
+      paths = [
+        rocm-developer-tools
+        rocm-ml-sdk
+        rocm-ml-libraries
+        rocm-hip-sdk
+        rocm-hip-libraries
+        rocm-openmp-sdk
+        rocm-opencl-sdk
+        rocm-opencl-runtime
+        rocm-hip-runtime-devel
+        rocm-hip-runtime
+        rocm-language-runtime
+      ];
+    };
+  };
+}
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/half/default.nix b/nixpkgs/pkgs/development/rocm-modules/5/half/default.nix
new file mode 100644
index 000000000000..08c645848fa2
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/half/default.nix
@@ -0,0 +1,39 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, rocmUpdateScript
+, cmake
+, rocm-cmake
+}:
+
+stdenv.mkDerivation (finalAttrs: {
+  pname = "half";
+  version = "5.7.0";
+
+  src = fetchFromGitHub {
+    owner = "ROCmSoftwarePlatform";
+    repo = "half";
+    rev = "rocm-${finalAttrs.version}";
+    hash = "sha256-82It+/wm8+umBdQYn7lz/fS69h+f0mzwPdGxoJNYUq0=";
+  };
+
+  nativeBuildInputs = [
+    cmake
+    rocm-cmake
+  ];
+
+  passthru.updateScript = rocmUpdateScript {
+    name = finalAttrs.pname;
+    owner = finalAttrs.src.owner;
+    repo = finalAttrs.src.repo;
+  };
+
+  meta = with lib; {
+    description = "C++ library for half precision floating point arithmetics";
+    homepage = "https://github.com/ROCmSoftwarePlatform/half";
+    license = with licenses; [ mit ];
+    maintainers = teams.rocm.members;
+    platforms = platforms.unix;
+    broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
+  };
+})
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/hip-common/default.nix b/nixpkgs/pkgs/development/rocm-modules/5/hip-common/default.nix
new file mode 100644
index 000000000000..9f5f37511ef0
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/hip-common/default.nix
@@ -0,0 +1,44 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, rocmUpdateScript
+}:
+
+stdenv.mkDerivation (finalAttrs: {
+  pname = "hip-common";
+  version = "5.7.0";
+
+  src = fetchFromGitHub {
+    owner = "ROCm-Developer-Tools";
+    repo = "HIP";
+    rev = "rocm-${finalAttrs.version}";
+    hash = "sha256-1Abit9qZCwrCVcnaFT4uMygFB9G6ovRasLmTsOsJ/Fw=";
+  };
+
+  dontConfigure = true;
+  dontBuild = true;
+
+  installPhase = ''
+    runHook preInstall
+
+    mkdir -p $out
+    mv * $out
+
+    runHook postInstall
+  '';
+
+  passthru.updateScript = rocmUpdateScript {
+    name = finalAttrs.pname;
+    owner = finalAttrs.src.owner;
+    repo = finalAttrs.src.repo;
+  };
+
+  meta = with lib; {
+    description = "C++ Heterogeneous-Compute Interface for Portability";
+    homepage = "https://github.com/ROCm-Developer-Tools/HIP";
+    license = with licenses; [ mit ];
+    maintainers = with maintainers; [ lovesegfault ] ++ teams.rocm.members;
+    platforms = platforms.linux;
+    broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
+  };
+})
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/hipblas/default.nix b/nixpkgs/pkgs/development/rocm-modules/5/hipblas/default.nix
new file mode 100644
index 000000000000..b2206c737b00
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/hipblas/default.nix
@@ -0,0 +1,99 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, rocmUpdateScript
+, cmake
+, rocm-cmake
+, clr
+, gfortran
+, rocblas
+, rocsolver
+, gtest
+, lapack-reference
+, buildTests ? false
+, buildBenchmarks ? false
+, buildSamples ? false
+}:
+
+# Can also use cuBLAS
+stdenv.mkDerivation (finalAttrs: {
+  pname = "hipblas";
+  version = "5.7.0";
+
+  outputs = [
+    "out"
+  ] ++ lib.optionals buildTests [
+    "test"
+  ] ++ lib.optionals buildBenchmarks [
+    "benchmark"
+  ] ++ lib.optionals buildSamples [
+    "sample"
+  ];
+
+  src = fetchFromGitHub {
+    owner = "ROCmSoftwarePlatform";
+    repo = "hipBLAS";
+    rev = "rocm-${finalAttrs.version}";
+    hash = "sha256-abaEZN82dsoEC5gIF3/6epRDVz5ItUo6CkZsybu/G+g=";
+  };
+
+  nativeBuildInputs = [
+    cmake
+    rocm-cmake
+    clr
+    gfortran
+  ];
+
+  buildInputs = [
+    rocblas
+    rocsolver
+  ] ++ lib.optionals buildTests [
+    gtest
+  ] ++ lib.optionals (buildTests || buildBenchmarks) [
+    lapack-reference
+  ];
+
+  cmakeFlags = [
+    "-DCMAKE_C_COMPILER=hipcc"
+    "-DCMAKE_CXX_COMPILER=hipcc"
+    # Manually define CMAKE_INSTALL_<DIR>
+    # See: https://github.com/NixOS/nixpkgs/pull/197838
+    "-DCMAKE_INSTALL_BINDIR=bin"
+    "-DCMAKE_INSTALL_LIBDIR=lib"
+    "-DCMAKE_INSTALL_INCLUDEDIR=include"
+  ] ++ lib.optionals buildTests [
+    "-DBUILD_CLIENTS_TESTS=ON"
+  ] ++ lib.optionals buildBenchmarks [
+    "-DBUILD_CLIENTS_BENCHMARKS=ON"
+  ] ++ lib.optionals buildSamples [
+    "-DBUILD_CLIENTS_SAMPLES=ON"
+  ];
+
+  postInstall = lib.optionalString buildTests ''
+    mkdir -p $test/bin
+    mv $out/bin/hipblas-test $test/bin
+  '' + lib.optionalString buildBenchmarks ''
+    mkdir -p $benchmark/bin
+    mv $out/bin/hipblas-bench $benchmark/bin
+  '' + lib.optionalString buildSamples ''
+    mkdir -p $sample/bin
+    mv $out/bin/example-* $sample/bin
+  '' + lib.optionalString (buildTests || buildBenchmarks || buildSamples) ''
+    rmdir $out/bin
+  '';
+
+  passthru.updateScript = rocmUpdateScript {
+    name = finalAttrs.pname;
+    owner = finalAttrs.src.owner;
+    repo = finalAttrs.src.repo;
+  };
+
+  meta = with lib; {
+    description = "ROCm BLAS marshalling library";
+    homepage = "https://github.com/ROCmSoftwarePlatform/hipBLAS";
+    license = with licenses; [ mit ];
+    maintainers = teams.rocm.members;
+    platforms = platforms.linux;
+    broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
+  };
+})
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/hipcc/default.nix b/nixpkgs/pkgs/development/rocm-modules/5/hipcc/default.nix
new file mode 100644
index 000000000000..e6610e8909f7
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/hipcc/default.nix
@@ -0,0 +1,46 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, rocmUpdateScript
+, cmake
+, lsb-release
+}:
+
+stdenv.mkDerivation (finalAttrs: {
+  pname = "hipcc";
+  version = "5.7.0";
+
+  src = fetchFromGitHub {
+    owner = "ROCm-Developer-Tools";
+    repo = "HIPCC";
+    rev = "rocm-${finalAttrs.version}";
+    hash = "sha256-lJX6nF1V4YmK5ai7jivXlRnG3doIOf6X9CWLHVdRuVg=";
+  };
+
+  nativeBuildInputs = [ cmake ];
+
+  postPatch = ''
+    substituteInPlace src/hipBin_amd.h \
+      --replace "/usr/bin/lsb_release" "${lsb-release}/bin/lsb_release"
+  '';
+
+  postInstall = ''
+    rm -r $out/hip/bin
+    ln -s $out/bin $out/hip/bin
+  '';
+
+  passthru.updateScript = rocmUpdateScript {
+    name = finalAttrs.pname;
+    owner = finalAttrs.src.owner;
+    repo = finalAttrs.src.repo;
+  };
+
+  meta = with lib; {
+    description = "Compiler driver utility that calls clang or nvcc";
+    homepage = "https://github.com/ROCm-Developer-Tools/HIPCC";
+    license = with licenses; [ mit ];
+    maintainers = with maintainers; [ lovesegfault ] ++ teams.rocm.members;
+    platforms = platforms.linux;
+    broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
+  };
+})
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/hipcub/default.nix b/nixpkgs/pkgs/development/rocm-modules/5/hipcub/default.nix
new file mode 100644
index 000000000000..447c2c4174af
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/hipcub/default.nix
@@ -0,0 +1,90 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, rocmUpdateScript
+, cmake
+, rocm-cmake
+, rocprim
+, clr
+, gtest
+, gbenchmark
+, buildTests ? false
+, buildBenchmarks ? false
+, gpuTargets ? [ ]
+}:
+
+# CUB can also be used as a backend instead of rocPRIM.
+stdenv.mkDerivation (finalAttrs: {
+  pname = "hipcub";
+  version = "5.7.0";
+
+  outputs = [
+    "out"
+  ] ++ lib.optionals buildTests [
+    "test"
+  ] ++ lib.optionals buildBenchmarks [
+    "benchmark"
+  ];
+
+  src = fetchFromGitHub {
+    owner = "ROCmSoftwarePlatform";
+    repo = "hipCUB";
+    rev = "rocm-${finalAttrs.version}";
+    hash = "sha256-ygBEA3NuCQ13QrSzGqyWXkx8Dy9WhR3u4syzapRTkFU=";
+  };
+
+  nativeBuildInputs = [
+    cmake
+    rocm-cmake
+    clr
+  ];
+
+  buildInputs = [
+    rocprim
+  ] ++ lib.optionals buildTests [
+    gtest
+  ] ++ lib.optionals buildBenchmarks [
+    gbenchmark
+  ];
+
+  cmakeFlags = [
+    "-DCMAKE_CXX_COMPILER=hipcc"
+    "-DHIP_ROOT_DIR=${clr}"
+    # Manually define CMAKE_INSTALL_<DIR>
+    # See: https://github.com/NixOS/nixpkgs/pull/197838
+    "-DCMAKE_INSTALL_BINDIR=bin"
+    "-DCMAKE_INSTALL_LIBDIR=lib"
+    "-DCMAKE_INSTALL_INCLUDEDIR=include"
+  ] ++ lib.optionals (gpuTargets != [ ]) [
+    "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}"
+  ] ++ lib.optionals buildTests [
+    "-DBUILD_TEST=ON"
+  ] ++ lib.optionals buildBenchmarks [
+    "-DBUILD_BENCHMARK=ON"
+  ];
+
+  postInstall = lib.optionalString buildTests ''
+    mkdir -p $test/bin
+    mv $out/bin/test_* $test/bin
+  '' + lib.optionalString buildBenchmarks ''
+    mkdir -p $benchmark/bin
+    mv $out/bin/benchmark_* $benchmark/bin
+  '' + lib.optionalString (buildTests || buildBenchmarks) ''
+    rmdir $out/bin
+  '';
+
+  passthru.updateScript = rocmUpdateScript {
+    name = finalAttrs.pname;
+    owner = finalAttrs.src.owner;
+    repo = finalAttrs.src.repo;
+  };
+
+  meta = with lib; {
+    description = "Thin wrapper library on top of rocPRIM or CUB";
+    homepage = "https://github.com/ROCmSoftwarePlatform/hipCUB";
+    license = with licenses; [ bsd3 ];
+    maintainers = teams.rocm.members;
+    platforms = platforms.linux;
+    broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
+  };
+})
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/hipfft/default.nix b/nixpkgs/pkgs/development/rocm-modules/5/hipfft/default.nix
new file mode 100644
index 000000000000..153a7c8c18cc
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/hipfft/default.nix
@@ -0,0 +1,110 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, rocmUpdateScript
+, cmake
+, rocm-cmake
+, clr
+, git
+, rocfft
+, gtest
+, boost
+, fftw
+, fftwFloat
+, openmp
+, buildTests ? false
+, buildBenchmarks ? false
+, buildSamples ? false
+, gpuTargets ? [ ]
+}:
+
+# Can also use cuFFT
+stdenv.mkDerivation (finalAttrs: {
+  pname = "hipfft";
+  version = "5.7.0";
+
+  outputs = [
+    "out"
+  ] ++ lib.optionals buildTests [
+    "test"
+  ] ++ lib.optionals buildBenchmarks [
+    "benchmark"
+  ] ++ lib.optionals buildSamples [
+    "sample"
+  ];
+
+  src = fetchFromGitHub {
+    owner = "ROCmSoftwarePlatform";
+    repo = "hipFFT";
+    rev = "rocm-${finalAttrs.version}";
+    hash = "sha256-fuYRKdlTrRMwxr3cgMeT3YniPzs4nuvF8YCzr3LLPFM=";
+    fetchSubmodules = true;
+  };
+
+  nativeBuildInputs = [
+    clr
+    git
+    cmake
+    rocm-cmake
+  ];
+
+  buildInputs = [
+    rocfft
+  ] ++ lib.optionals (buildTests || buildBenchmarks || buildSamples) [
+    gtest
+    boost
+    fftw
+    fftwFloat
+    openmp
+  ];
+
+  cmakeFlags = [
+    "-DCMAKE_C_COMPILER=hipcc"
+    "-DCMAKE_CXX_COMPILER=hipcc"
+    "-DCMAKE_MODULE_PATH=${clr}/lib/cmake/hip"
+    "-DHIP_ROOT_DIR=${clr}"
+    "-DHIP_PATH=${clr}"
+    # Manually define CMAKE_INSTALL_<DIR>
+    # See: https://github.com/NixOS/nixpkgs/pull/197838
+    "-DCMAKE_INSTALL_BINDIR=bin"
+    "-DCMAKE_INSTALL_LIBDIR=lib"
+    "-DCMAKE_INSTALL_INCLUDEDIR=include"
+  ] ++ lib.optionals (gpuTargets != [ ]) [
+    "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}"
+  ] ++ lib.optionals buildTests [
+    "-DBUILD_CLIENTS_TESTS=ON"
+  ] ++ lib.optionals buildBenchmarks [
+    "-DBUILD_CLIENTS_RIDER=ON"
+  ] ++ lib.optionals buildSamples [
+    "-DBUILD_CLIENTS_SAMPLES=ON"
+  ];
+
+  postInstall = lib.optionalString buildTests ''
+    mkdir -p $test/bin
+    mv $out/bin/hipfft-test $test/bin
+  '' + lib.optionalString buildBenchmarks ''
+    mkdir -p $benchmark/bin
+    mv $out/bin/hipfft-rider $benchmark/bin
+  '' + lib.optionalString buildSamples ''
+    mkdir -p $sample/bin
+    mv clients/staging/hipfft_* $sample/bin
+    patchelf $sample/bin/hipfft_* --shrink-rpath --allowed-rpath-prefixes "$NIX_STORE"
+  '' + lib.optionalString (buildTests || buildBenchmarks) ''
+    rmdir $out/bin
+  '';
+
+  passthru.updateScript = rocmUpdateScript {
+    name = finalAttrs.pname;
+    owner = finalAttrs.src.owner;
+    repo = finalAttrs.src.repo;
+  };
+
+  meta = with lib; {
+    description = "FFT marshalling library";
+    homepage = "https://github.com/ROCmSoftwarePlatform/hipFFT";
+    license = with licenses; [ mit ];
+    maintainers = teams.rocm.members;
+    platforms = platforms.linux;
+    broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
+  };
+})
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/hipfort/default.nix b/nixpkgs/pkgs/development/rocm-modules/5/hipfort/default.nix
new file mode 100644
index 000000000000..4bb2a270271b
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/hipfort/default.nix
@@ -0,0 +1,66 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, rocmUpdateScript
+, cmake
+, rocm-cmake
+, gfortran
+}:
+
+stdenv.mkDerivation (finalAttrs: {
+  pname = "hipfort";
+  version = "5.7.0";
+
+  src = fetchFromGitHub {
+    owner = "ROCmSoftwarePlatform";
+    repo = "hipfort";
+    rev = "rocm-${finalAttrs.version}";
+    hash = "sha256-DRjUWhdinDKP7CZgq2SmU3lGmmodCuXvco9aEeMLSZ4=";
+  };
+
+  nativeBuildInputs = [
+    cmake
+    rocm-cmake
+    gfortran
+  ];
+
+  cmakeFlags = [
+    "-DHIPFORT_COMPILER=${gfortran}/bin/gfortran"
+    "-DHIPFORT_AR=${gfortran.cc}/bin/gcc-ar"
+    "-DHIPFORT_RANLIB=${gfortran.cc}/bin/gcc-ranlib"
+    # Manually define CMAKE_INSTALL_<DIR>
+    # See: https://github.com/NixOS/nixpkgs/pull/197838
+    "-DCMAKE_INSTALL_BINDIR=bin"
+    "-DCMAKE_INSTALL_LIBDIR=lib"
+    "-DCMAKE_INSTALL_INCLUDEDIR=include"
+  ];
+
+  postPatch = ''
+    patchShebangs bin
+
+    substituteInPlace bin/hipfc bin/mymcpu \
+      --replace "/bin/cat" "cat"
+
+    substituteInPlace bin/CMakeLists.txt \
+      --replace "/bin/mkdir" "mkdir" \
+      --replace "/bin/cp" "cp" \
+      --replace "/bin/sed" "sed" \
+      --replace "/bin/chmod" "chmod" \
+      --replace "/bin/ln" "ln"
+  '';
+
+  passthru.updateScript = rocmUpdateScript {
+    name = finalAttrs.pname;
+    owner = finalAttrs.src.owner;
+    repo = finalAttrs.src.repo;
+  };
+
+  meta = with lib; {
+    description = "Fortran interfaces for ROCm libraries";
+    homepage = "https://github.com/ROCmSoftwarePlatform/hipfort";
+    license = with licenses; [ mit ]; # mitx11
+    maintainers = teams.rocm.members;
+    platforms = platforms.linux;
+    broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
+  };
+})
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/hipify/default.nix b/nixpkgs/pkgs/development/rocm-modules/5/hipify/default.nix
new file mode 100644
index 000000000000..893056496c9c
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/hipify/default.nix
@@ -0,0 +1,50 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, rocmUpdateScript
+, cmake
+, clang
+, libxml2
+}:
+
+stdenv.mkDerivation (finalAttrs: {
+  pname = "hipify";
+  version = "5.7.0";
+
+  src = fetchFromGitHub {
+    owner = "ROCm-Developer-Tools";
+    repo = "HIPIFY";
+    rev = "rocm-${finalAttrs.version}";
+    hash = "sha256-lCQ2VTUGmFC90Xu70/tvoeDhFaInGqLT3vC2A1UojNI=";
+  };
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ libxml2 ];
+
+  postPatch = ''
+    substituteInPlace CMakeLists.txt \
+      --replace "\''${LLVM_TOOLS_BINARY_DIR}/clang" "${clang}/bin/clang"
+  '';
+
+  passthru.updateScript = rocmUpdateScript {
+    name = finalAttrs.pname;
+    owner = finalAttrs.src.owner;
+    repo = finalAttrs.src.repo;
+  };
+
+  # Fixup bad symlinks
+  postInstall = ''
+    rm -r $out/hip/bin
+    ln -s $out/bin $out/hip/bin
+    patchShebangs $out/bin
+  '';
+
+  meta = with lib; {
+    description = "Convert CUDA to Portable C++ Code";
+    homepage = "https://github.com/ROCm-Developer-Tools/HIPIFY";
+    license = with licenses; [ mit ];
+    maintainers = teams.rocm.members;
+    platforms = platforms.linux;
+    broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
+  };
+})
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/hipsolver/default.nix b/nixpkgs/pkgs/development/rocm-modules/5/hipsolver/default.nix
new file mode 100644
index 000000000000..34592a5bbd96
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/hipsolver/default.nix
@@ -0,0 +1,100 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, rocmUpdateScript
+, cmake
+, rocm-cmake
+, clr
+, gfortran
+, rocblas
+, rocsolver
+, gtest
+, lapack-reference
+, buildTests ? false
+, buildBenchmarks ? false
+, buildSamples ? false
+}:
+
+# Can also use cuSOLVER
+stdenv.mkDerivation (finalAttrs: {
+  pname = "hipsolver";
+  version = "5.7.0";
+
+  outputs = [
+    "out"
+  ] ++ lib.optionals buildTests [
+    "test"
+  ] ++ lib.optionals buildBenchmarks [
+    "benchmark"
+  ] ++ lib.optionals buildSamples [
+    "sample"
+  ];
+
+  src = fetchFromGitHub {
+    owner = "ROCmSoftwarePlatform";
+    repo = "hipSOLVER";
+    rev = "rocm-${finalAttrs.version}";
+    hash = "sha256-I9Xjkilo+baeM1CRXjLAbj/vrg8r5/E2yEImhHGSyf8=";
+  };
+
+  nativeBuildInputs = [
+    cmake
+    rocm-cmake
+    clr
+    gfortran
+  ];
+
+  buildInputs = [
+    rocblas
+    rocsolver
+  ] ++ lib.optionals buildTests [
+    gtest
+  ] ++ lib.optionals (buildTests || buildBenchmarks) [
+    lapack-reference
+  ];
+
+  cmakeFlags = [
+    "-DCMAKE_C_COMPILER=hipcc"
+    "-DCMAKE_CXX_COMPILER=hipcc"
+    # Manually define CMAKE_INSTALL_<DIR>
+    # See: https://github.com/NixOS/nixpkgs/pull/197838
+    "-DCMAKE_INSTALL_BINDIR=bin"
+    "-DCMAKE_INSTALL_LIBDIR=lib"
+    "-DCMAKE_INSTALL_INCLUDEDIR=include"
+  ] ++ lib.optionals buildTests [
+    "-DBUILD_CLIENTS_TESTS=ON"
+  ] ++ lib.optionals buildBenchmarks [
+    "-DBUILD_CLIENTS_BENCHMARKS=ON"
+  ] ++ lib.optionals buildSamples [
+    "-DBUILD_CLIENTS_SAMPLES=ON"
+  ];
+
+  postInstall = lib.optionalString buildTests ''
+    mkdir -p $test/bin
+    mv $out/bin/hipsolver-test $test/bin
+  '' + lib.optionalString buildBenchmarks ''
+    mkdir -p $benchmark/bin
+    mv $out/bin/hipsolver-bench $benchmark/bin
+  '' + lib.optionalString buildSamples ''
+    mkdir -p $sample/bin
+    mv clients/staging/example-* $sample/bin
+    patchelf $sample/bin/example-* --shrink-rpath --allowed-rpath-prefixes "$NIX_STORE"
+  '' + lib.optionalString (buildTests || buildBenchmarks) ''
+    rmdir $out/bin
+  '';
+
+  passthru.updateScript = rocmUpdateScript {
+    name = finalAttrs.pname;
+    owner = finalAttrs.src.owner;
+    repo = finalAttrs.src.repo;
+  };
+
+  meta = with lib; {
+    description = "ROCm SOLVER marshalling library";
+    homepage = "https://github.com/ROCmSoftwarePlatform/hipSOLVER";
+    license = with licenses; [ mit ];
+    maintainers = teams.rocm.members;
+    platforms = platforms.linux;
+    broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
+  };
+})
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/hipsparse/default.nix b/nixpkgs/pkgs/development/rocm-modules/5/hipsparse/default.nix
new file mode 100644
index 000000000000..79b78f3661d8
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/hipsparse/default.nix
@@ -0,0 +1,136 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, rocmUpdateScript
+, cmake
+, rocm-cmake
+, rocsparse
+, clr
+, gfortran
+, git
+, gtest
+, openmp
+, buildTests ? false
+, buildSamples ? false
+, gpuTargets ? [ ]
+}:
+
+# This can also use cuSPARSE as a backend instead of rocSPARSE
+stdenv.mkDerivation (finalAttrs: {
+  pname = "hipsparse";
+  version = "5.7.0";
+
+  outputs = [
+    "out"
+  ] ++ lib.optionals buildTests [
+    "test"
+  ] ++ lib.optionals buildSamples [
+    "sample"
+  ];
+
+  src = fetchFromGitHub {
+    owner = "ROCmSoftwarePlatform";
+    repo = "hipSPARSE";
+    rev = "rocm-${finalAttrs.version}";
+    hash = "sha256-txigaOoZMI/v+EQLgGlj2O0IHfE7EpgjL0cyv49nKzo=";
+  };
+
+  nativeBuildInputs = [
+    cmake
+    rocm-cmake
+    clr
+    gfortran
+  ];
+
+  buildInputs = [
+    rocsparse
+    git
+  ] ++ lib.optionals buildTests [
+    gtest
+  ] ++ lib.optionals (buildTests || buildSamples) [
+    openmp
+  ];
+
+  cmakeFlags = [
+    "-DCMAKE_C_COMPILER=hipcc"
+    "-DCMAKE_CXX_COMPILER=hipcc"
+    "-DBUILD_CLIENTS_SAMPLES=${if buildSamples then "ON" else "OFF"}"
+    # Manually define CMAKE_INSTALL_<DIR>
+    # See: https://github.com/NixOS/nixpkgs/pull/197838
+    "-DCMAKE_INSTALL_BINDIR=bin"
+    "-DCMAKE_INSTALL_LIBDIR=lib"
+    "-DCMAKE_INSTALL_INCLUDEDIR=include"
+  ] ++ lib.optionals (gpuTargets != [ ]) [
+    "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}"
+  ] ++ lib.optionals buildTests [
+    "-DBUILD_CLIENTS_TESTS=ON"
+  ];
+
+  # We have to manually generate the matrices
+  # CMAKE_MATRICES_DIR seems to be reset in clients/tests/CMakeLists.txt
+  postPatch = lib.optionalString buildTests ''
+    mkdir -p matrices
+
+    ln -s ${rocsparse.passthru.matrices.matrix-01}/*.mtx matrices
+    ln -s ${rocsparse.passthru.matrices.matrix-02}/*.mtx matrices
+    ln -s ${rocsparse.passthru.matrices.matrix-03}/*.mtx matrices
+    ln -s ${rocsparse.passthru.matrices.matrix-04}/*.mtx matrices
+    ln -s ${rocsparse.passthru.matrices.matrix-05}/*.mtx matrices
+    ln -s ${rocsparse.passthru.matrices.matrix-06}/*.mtx matrices
+    ln -s ${rocsparse.passthru.matrices.matrix-07}/*.mtx matrices
+    ln -s ${rocsparse.passthru.matrices.matrix-08}/*.mtx matrices
+    ln -s ${rocsparse.passthru.matrices.matrix-09}/*.mtx matrices
+    ln -s ${rocsparse.passthru.matrices.matrix-10}/*.mtx matrices
+    ln -s ${rocsparse.passthru.matrices.matrix-11}/*.mtx matrices
+    ln -s ${rocsparse.passthru.matrices.matrix-12}/*.mtx matrices
+    ln -s ${rocsparse.passthru.matrices.matrix-13}/*.mtx matrices
+    ln -s ${rocsparse.passthru.matrices.matrix-14}/*.mtx matrices
+    ln -s ${rocsparse.passthru.matrices.matrix-15}/*.mtx matrices
+    ln -s ${rocsparse.passthru.matrices.matrix-16}/*.mtx matrices
+    ln -s ${rocsparse.passthru.matrices.matrix-17}/*.mtx matrices
+    ln -s ${rocsparse.passthru.matrices.matrix-18}/*.mtx matrices
+    ln -s ${rocsparse.passthru.matrices.matrix-19}/*.mtx matrices
+
+    # Not used by the original cmake, causes an error
+    rm matrices/*_b.mtx
+
+    echo "deps/convert.cpp -> deps/mtx2csr"
+    hipcc deps/convert.cpp -O3 -o deps/mtx2csr
+
+    for mat in $(ls -1 matrices | cut -d "." -f 1); do
+      echo "mtx2csr: $mat.mtx -> $mat.bin"
+      deps/mtx2csr matrices/$mat.mtx matrices/$mat.bin
+      unlink matrices/$mat.mtx
+    done
+
+    substituteInPlace clients/tests/CMakeLists.txt \
+      --replace "\''${PROJECT_BINARY_DIR}/matrices" "/build/source/matrices"
+  '';
+
+  postInstall = lib.optionalString buildTests ''
+    mkdir -p $test/bin
+    mv $out/bin/hipsparse-test $test/bin
+    mv /build/source/matrices $test
+    rmdir $out/bin
+  '' + lib.optionalString buildSamples ''
+    mkdir -p $sample/bin
+    mv clients/staging/example_* $sample/bin
+    patchelf --set-rpath $out/lib:${lib.makeLibraryPath (
+      finalAttrs.buildInputs ++ [ clr gfortran.cc ])} $sample/bin/example_*
+  '';
+
+  passthru.updateScript = rocmUpdateScript {
+    name = finalAttrs.pname;
+    owner = finalAttrs.src.owner;
+    repo = finalAttrs.src.repo;
+  };
+
+  meta = with lib; {
+    description = "ROCm SPARSE marshalling library";
+    homepage = "https://github.com/ROCmSoftwarePlatform/hipSPARSE";
+    license = with licenses; [ mit ];
+    maintainers = teams.rocm.members;
+    platforms = platforms.linux;
+    broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
+  };
+})
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/hsa-amd-aqlprofile-bin/default.nix b/nixpkgs/pkgs/development/rocm-modules/5/hsa-amd-aqlprofile-bin/default.nix
new file mode 100644
index 000000000000..d13092fd3eef
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/hsa-amd-aqlprofile-bin/default.nix
@@ -0,0 +1,45 @@
+{ lib
+, stdenv
+, fetchurl
+, dpkg
+}:
+
+let
+  prefix = "hsa-amd-aqlprofile";
+  version = "5.7.0";
+  major = lib.versions.major version;
+  minor = lib.versions.minor version;
+  patch = lib.versions.patch version;
+  magic = lib.strings.concatStrings (lib.strings.intersperse "0" (lib.versions.splitVersion version));
+in stdenv.mkDerivation (finalAttrs: {
+  inherit version;
+  pname = "${prefix}-bin";
+
+  src = fetchurl {
+    url = "https://repo.radeon.com/rocm/apt/${major}.${minor}/pool/main/h/${prefix}/${prefix}_1.0.0.${magic}.${magic}-63~22.04_amd64.deb";
+    hash = "sha256-FQ25eXkhnvOmcf0sGW3GYu9kZj69bVvZrh0jVx/G/kI=";
+  };
+
+  nativeBuildInputs = [ dpkg ];
+  dontPatch = true;
+  dontConfigure = true;
+  dontBuild = true;
+
+  installPhase = ''
+    runHook preInstall
+
+    mkdir -p $out
+    cp -a opt/rocm-${version}/* $out
+
+    runHook postInstall
+  '';
+
+  meta = with lib; {
+    description = "AQLPROFILE library for AMD HSA runtime API extension support";
+    homepage = "https://rocm.docs.amd.com/en/latest/";
+    license = with licenses; [ unfree ];
+    maintainers = teams.rocm.members;
+    platforms = platforms.linux;
+    broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
+  };
+})
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/llvm/base.nix b/nixpkgs/pkgs/development/rocm-modules/5/llvm/base.nix
new file mode 100644
index 000000000000..655192d892bb
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/llvm/base.nix
@@ -0,0 +1,167 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, rocmUpdateScript
+, pkg-config
+, cmake
+, ninja
+, git
+, doxygen
+, sphinx
+, lit
+, libxml2
+, libxcrypt
+, libedit
+, libffi
+, mpfr
+, zlib
+, ncurses
+, python3Packages
+, buildDocs ? true
+, buildMan ? true
+, buildTests ? true
+, targetName ? "llvm"
+, targetDir ? "llvm"
+, targetProjects ? [ ]
+, targetRuntimes ? [ ]
+, llvmTargetsToBuild ? [ "NATIVE" ] # "NATIVE" resolves into x86 or aarch64 depending on stdenv
+, extraPatches ? [ ]
+, extraNativeBuildInputs ? [ ]
+, extraBuildInputs ? [ ]
+, extraCMakeFlags ? [ ]
+, extraPostPatch ? ""
+, checkTargets ? [(
+  lib.optionalString buildTests (
+    if targetDir == "runtimes"
+    then "check-runtimes"
+    else "check-all"
+  )
+)]
+, extraPostInstall ? ""
+, hardeningDisable ? [ ]
+, requiredSystemFeatures ? [ ]
+, extraLicenses ? [ ]
+, isBroken ? false
+}:
+
+let
+  llvmNativeTarget =
+    if stdenv.isx86_64 then "X86"
+    else if stdenv.isAarch64 then "AArch64"
+    else throw "Unsupported ROCm LLVM platform";
+  inferNativeTarget = t: if t == "NATIVE" then llvmNativeTarget else t;
+  llvmTargetsToBuild' = [ "AMDGPU" ] ++ builtins.map inferNativeTarget llvmTargetsToBuild;
+in stdenv.mkDerivation (finalAttrs: {
+  pname = "rocm-llvm-${targetName}";
+  version = "5.7.0";
+
+  outputs = [
+    "out"
+  ] ++ lib.optionals buildDocs [
+    "doc"
+  ] ++ lib.optionals buildMan [
+    "man"
+    "info" # Avoid `attribute 'info' missing` when using with wrapCC
+  ];
+
+  patches = extraPatches;
+
+  src = fetchFromGitHub {
+    owner = "RadeonOpenCompute";
+    repo = "llvm-project";
+    rev = "rocm-${finalAttrs.version}";
+    hash = "sha256-oJIXALwxo130jl8b6yCFw+a2kMBlny5/0ubiqF6MOWY=";
+  };
+
+  nativeBuildInputs = [
+    pkg-config
+    cmake
+    ninja
+    git
+    python3Packages.python
+  ] ++ lib.optionals (buildDocs || buildMan) [
+    doxygen
+    sphinx
+    python3Packages.recommonmark
+  ] ++ lib.optionals (buildTests && !finalAttrs.passthru.isLLVM) [
+    lit
+  ] ++ extraNativeBuildInputs;
+
+  buildInputs = [
+    libxml2
+    libxcrypt
+    libedit
+    libffi
+    mpfr
+  ] ++ extraBuildInputs;
+
+  propagatedBuildInputs = lib.optionals finalAttrs.passthru.isLLVM [
+    zlib
+    ncurses
+  ];
+
+  sourceRoot = "${finalAttrs.src.name}/${targetDir}";
+
+  cmakeFlags = [
+    "-DLLVM_TARGETS_TO_BUILD=${builtins.concatStringsSep ";" llvmTargetsToBuild'}"
+  ] ++ lib.optionals (finalAttrs.passthru.isLLVM && targetProjects != [ ]) [
+    "-DLLVM_ENABLE_PROJECTS=${lib.concatStringsSep ";" targetProjects}"
+  ] ++ lib.optionals ((finalAttrs.passthru.isLLVM || targetDir == "runtimes") && targetRuntimes != [ ]) [
+    "-DLLVM_ENABLE_RUNTIMES=${lib.concatStringsSep ";" targetRuntimes}"
+  ] ++ lib.optionals finalAttrs.passthru.isLLVM [
+    "-DLLVM_INSTALL_UTILS=ON"
+    "-DLLVM_INSTALL_GTEST=ON"
+  ] ++ lib.optionals (buildDocs || buildMan) [
+    "-DLLVM_INCLUDE_DOCS=ON"
+    "-DLLVM_BUILD_DOCS=ON"
+    # "-DLLVM_ENABLE_DOXYGEN=ON" Way too slow, only uses one core
+    "-DLLVM_ENABLE_SPHINX=ON"
+    "-DSPHINX_OUTPUT_HTML=ON"
+    "-DSPHINX_OUTPUT_MAN=ON"
+    "-DSPHINX_WARNINGS_AS_ERRORS=OFF"
+  ] ++ lib.optionals buildTests [
+    "-DLLVM_INCLUDE_TESTS=ON"
+    "-DLLVM_BUILD_TESTS=ON"
+    "-DLLVM_EXTERNAL_LIT=${lit}/bin/.lit-wrapped"
+  ] ++ extraCMakeFlags;
+
+  postPatch = lib.optionalString finalAttrs.passthru.isLLVM ''
+    patchShebangs lib/OffloadArch/make_generated_offload_arch_h.sh
+  '' + lib.optionalString (buildTests && finalAttrs.passthru.isLLVM) ''
+    # FileSystem permissions tests fail with various special bits
+    rm test/tools/llvm-objcopy/ELF/mirror-permissions-unix.test
+    rm unittests/Support/Path.cpp
+
+    substituteInPlace unittests/Support/CMakeLists.txt \
+      --replace "Path.cpp" ""
+  '' + extraPostPatch;
+
+  doCheck = buildTests;
+  checkTarget = lib.concatStringsSep " " checkTargets;
+
+  postInstall = lib.optionalString buildMan ''
+    mkdir -p $info
+  '' + extraPostInstall;
+
+  passthru = {
+    isLLVM = targetDir == "llvm";
+    isClang = targetDir == "clang" || builtins.elem "clang" targetProjects;
+
+    updateScript = rocmUpdateScript {
+      name = finalAttrs.pname;
+      owner = finalAttrs.src.owner;
+      repo = finalAttrs.src.repo;
+    };
+  };
+
+  inherit hardeningDisable requiredSystemFeatures;
+
+  meta = with lib; {
+    description = "ROCm fork of the LLVM compiler infrastructure";
+    homepage = "https://github.com/RadeonOpenCompute/llvm-project";
+    license = with licenses; [ ncsa ] ++ extraLicenses;
+    maintainers = with maintainers; [ acowley lovesegfault ] ++ teams.rocm.members;
+    platforms = platforms.linux;
+    broken = isBroken;
+  };
+})
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/llvm/default.nix b/nixpkgs/pkgs/development/rocm-modules/5/llvm/default.nix
new file mode 100644
index 000000000000..9226fb87802c
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/llvm/default.nix
@@ -0,0 +1,57 @@
+{ stdenv
+, callPackage
+, rocmUpdateScript
+, wrapBintoolsWith
+, overrideCC
+, rocm-device-libs
+, rocm-runtime
+, rocm-thunk
+, clr
+}:
+
+let
+  ## Stage 1 ##
+  # Projects
+  llvm = callPackage ./stage-1/llvm.nix { inherit rocmUpdateScript; };
+  clang-unwrapped = callPackage ./stage-1/clang-unwrapped.nix { inherit rocmUpdateScript llvm; };
+  lld = callPackage ./stage-1/lld.nix { inherit rocmUpdateScript llvm; };
+
+  # Runtimes
+  runtimes = callPackage ./stage-1/runtimes.nix { inherit rocmUpdateScript llvm; };
+
+  ## Stage 2 ##
+  # Helpers
+  bintools-unwrapped = callPackage ./stage-2/bintools-unwrapped.nix { inherit llvm lld; };
+  bintools = wrapBintoolsWith { bintools = bintools-unwrapped; };
+  rStdenv = callPackage ./stage-2/rstdenv.nix { inherit llvm clang-unwrapped lld runtimes bintools; };
+in rec {
+  inherit
+  llvm
+  clang-unwrapped
+  lld
+  bintools;
+
+  # Runtimes
+  libc = callPackage ./stage-2/libc.nix { inherit rocmUpdateScript; stdenv = rStdenv; };
+  libunwind = callPackage ./stage-2/libunwind.nix { inherit rocmUpdateScript; stdenv = rStdenv; };
+  libcxxabi = callPackage ./stage-2/libcxxabi.nix { inherit rocmUpdateScript; stdenv = rStdenv; };
+  libcxx = callPackage ./stage-2/libcxx.nix { inherit rocmUpdateScript; stdenv = rStdenv; };
+  compiler-rt = callPackage ./stage-2/compiler-rt.nix { inherit rocmUpdateScript llvm; stdenv = rStdenv; };
+
+  ## Stage 3 ##
+  # Helpers
+  clang = callPackage ./stage-3/clang.nix { inherit llvm lld clang-unwrapped bintools libc libunwind libcxxabi libcxx compiler-rt; };
+  rocmClangStdenv = overrideCC stdenv clang;
+
+  # Projects
+  clang-tools-extra = callPackage ./stage-3/clang-tools-extra.nix { inherit rocmUpdateScript llvm clang-unwrapped; stdenv = rocmClangStdenv; };
+  libclc = callPackage ./stage-3/libclc.nix { inherit rocmUpdateScript llvm clang; stdenv = rocmClangStdenv; };
+  lldb = callPackage ./stage-3/lldb.nix { inherit rocmUpdateScript clang; stdenv = rocmClangStdenv; };
+  mlir = callPackage ./stage-3/mlir.nix { inherit rocmUpdateScript clr; stdenv = rocmClangStdenv; };
+  polly = callPackage ./stage-3/polly.nix { inherit rocmUpdateScript; stdenv = rocmClangStdenv; };
+  flang = callPackage ./stage-3/flang.nix { inherit rocmUpdateScript clang-unwrapped mlir; stdenv = rocmClangStdenv; };
+  openmp = callPackage ./stage-3/openmp.nix { inherit rocmUpdateScript llvm clang-unwrapped clang rocm-device-libs rocm-runtime rocm-thunk; stdenv = rocmClangStdenv; };
+
+  # Runtimes
+  pstl = callPackage ./stage-3/pstl.nix { inherit rocmUpdateScript; stdenv = rocmClangStdenv; };
+}
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-1/clang-unwrapped.nix b/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-1/clang-unwrapped.nix
new file mode 100644
index 000000000000..113313f4e066
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-1/clang-unwrapped.nix
@@ -0,0 +1,46 @@
+{ callPackage
+, rocmUpdateScript
+, llvm
+}:
+
+callPackage ../base.nix rec {
+  inherit rocmUpdateScript;
+  targetName = "clang-unwrapped";
+  targetDir = "clang";
+  extraBuildInputs = [ llvm ];
+
+  extraCMakeFlags = [
+    "-DCLANG_INCLUDE_DOCS=ON"
+    "-DCLANG_INCLUDE_TESTS=ON"
+  ];
+
+  extraPostPatch = ''
+    # Looks like they forgot to add finding libedit to the standalone build
+    ln -s ../cmake/Modules/FindLibEdit.cmake cmake/modules
+
+    substituteInPlace CMakeLists.txt \
+      --replace "include(CheckIncludeFile)" "include(CheckIncludeFile)''\nfind_package(LibEdit)"
+
+    # `No such file or directory: '/build/source/clang/tools/scan-build/bin/scan-build'`
+    rm test/Analysis/scan-build/*.test
+    rm test/Analysis/scan-build/rebuild_index/rebuild_index.test
+
+    # `does not depend on a module exporting 'baz.h'`
+    rm test/Modules/header-attribs.cpp
+
+    # We do not have HIP or the ROCm stack available yet
+    rm test/Driver/hip-options.hip
+
+    # ???? `ld: cannot find crti.o: No such file or directory` linker issue?
+    rm test/Interpreter/dynamic-library.cpp
+
+    # `fatal error: 'stdio.h' file not found`
+    rm test/OpenMP/amdgcn_emit_llvm.c
+  '';
+
+  extraPostInstall = ''
+    mv bin/clang-tblgen $out/bin
+  '';
+
+  requiredSystemFeatures = [ "big-parallel" ];
+}
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-1/lld.nix b/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-1/lld.nix
new file mode 100644
index 000000000000..a7b042eabfe6
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-1/lld.nix
@@ -0,0 +1,13 @@
+{ callPackage
+, rocmUpdateScript
+, llvm
+}:
+
+callPackage ../base.nix rec {
+  inherit rocmUpdateScript;
+  buildMan = false; # No man pages to build
+  targetName = "lld";
+  targetDir = targetName;
+  extraBuildInputs = [ llvm ];
+  checkTargets = [ "check-${targetName}" ];
+}
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-1/llvm.nix b/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-1/llvm.nix
new file mode 100644
index 000000000000..51959ec8bc32
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-1/llvm.nix
@@ -0,0 +1,10 @@
+{ stdenv
+, callPackage
+, rocmUpdateScript
+}:
+
+callPackage ../base.nix {
+  inherit rocmUpdateScript;
+  requiredSystemFeatures = [ "big-parallel" ];
+  isBroken = stdenv.isAarch64; # https://github.com/RadeonOpenCompute/ROCm/issues/1831#issuecomment-1278205344
+}
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-1/runtimes.nix b/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-1/runtimes.nix
new file mode 100644
index 000000000000..5f6f278ab10e
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-1/runtimes.nix
@@ -0,0 +1,30 @@
+{ lib
+, callPackage
+, rocmUpdateScript
+, llvm
+}:
+
+callPackage ../base.nix rec {
+  inherit rocmUpdateScript;
+  buildDocs = false;
+  buildMan = false;
+  buildTests = false;
+  targetName = "runtimes";
+  targetDir = targetName;
+
+  targetRuntimes = [
+    "libunwind"
+    "libcxxabi"
+    "libcxx"
+    "compiler-rt"
+  ];
+
+  extraBuildInputs = [ llvm ];
+
+  extraCMakeFlags = [
+    "-DLIBCXX_INCLUDE_BENCHMARKS=OFF"
+    "-DLIBCXX_CXX_ABI=libcxxabi"
+  ];
+
+  extraLicenses = [ lib.licenses.mit ];
+}
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-2/1000-libcxx-failing-tests.list b/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-2/1000-libcxx-failing-tests.list
new file mode 100644
index 000000000000..e005d6c928c2
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-2/1000-libcxx-failing-tests.list
@@ -0,0 +1,171 @@
+../libcxx/test/libcxx/containers/gnu_cxx/hash_map.pass.cpp
+../libcxx/test/libcxx/containers/gnu_cxx/hash_set.pass.cpp
+../libcxx/test/libcxx/depr/depr.default.allocator/allocator.members/allocate.cxx2a.pass.cpp
+../libcxx/test/libcxx/depr/depr.default.allocator/allocator.members/construct.cxx2a.pass.cpp
+../libcxx/test/libcxx/input.output/filesystems/class.directory_entry/directory_entry.mods/last_write_time.pass.cpp
+../libcxx/test/libcxx/input.output/filesystems/class.path/path.member/path.native.obs/string_alloc.pass.cpp
+../libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp
+../libcxx/test/libcxx/localization/locales/locale/locale.types/locale.facet/no_allocation.pass.cpp
+../libcxx/test/libcxx/utilities/utility/mem.res/mem.res.monotonic.buffer/mem.res.monotonic.buffer.mem/allocate_from_underaligned_buffer.pass.cpp
+../libcxx/test/libcxx/utilities/utility/mem.res/mem.res.monotonic.buffer/mem.res.monotonic.buffer.mem/allocate_in_geometric_progression.pass.cpp
+../libcxx/test/std/containers/associative/map/map.access/index_key.pass.cpp
+../libcxx/test/std/containers/associative/map/map.access/index_rv_key.pass.cpp
+../libcxx/test/std/containers/associative/map/map.modifiers/insert_and_emplace_allocator_requirements.pass.cpp
+../libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_allocator_requirements.pass.cpp
+../libcxx/test/std/containers/associative/multiset/insert_emplace_allocator_requirements.pass.cpp
+../libcxx/test/std/containers/associative/set/insert_and_emplace_allocator_requirements.pass.cpp
+../libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_iter_iter.pass.cpp
+../libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp
+../libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_value.pass.cpp
+../libcxx/test/std/containers/sequences/vector.bool/ctor_exceptions.pass.cpp
+../libcxx/test/std/containers/sequences/vector/vector.cons/exceptions.pass.cpp
+../libcxx/test/std/containers/unord/unord.map/unord.map.elem/index.pass.cpp
+../libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_and_emplace_allocator_requirements.pass.cpp
+../libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_allocator_requirements.pass.cpp
+../libcxx/test/std/containers/unord/unord.multiset/insert_emplace_allocator_requirements.pass.cpp
+../libcxx/test/std/containers/unord/unord.set/insert_and_emplace_allocator_requirements.pass.cpp
+../libcxx/test/std/experimental/memory/memory.resource.global/new_delete_resource.pass.cpp
+../libcxx/test/std/experimental/memory/memory.resource.global/null_memory_resource.pass.cpp
+../libcxx/test/std/input.output/file.streams/fstreams/filebuf.virtuals/pbackfail.pass.cpp
+../libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.cons/copy_assign.pass.cpp
+../libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.cons/copy.pass.cpp
+../libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.cons/move_assign.pass.cpp
+../libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.cons/move.pass.cpp
+../libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.cons/path.pass.cpp
+../libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.mods/assign.pass.cpp
+../libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.mods/refresh.pass.cpp
+../libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.mods/replace_filename.pass.cpp
+../libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/file_size.pass.cpp
+../libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/file_type_obs.pass.cpp
+../libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/hard_link_count.pass.cpp
+../libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/last_write_time.pass.cpp
+../libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/status.pass.cpp
+../libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/symlink_status.pass.cpp
+../libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/copy_assign.pass.cpp
+../libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/copy.pass.cpp
+../libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/ctor.pass.cpp
+../libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/increment.pass.cpp
+../libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/move_assign.pass.cpp
+../libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/move.pass.cpp
+../libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.nonmembers/begin_end.pass.cpp
+../libcxx/test/std/input.output/filesystems/class.path/path.member/path.append.pass.cpp
+../libcxx/test/std/input.output/filesystems/class.path/path.member/path.assign/move.pass.cpp
+../libcxx/test/std/input.output/filesystems/class.path/path.member/path.assign/source.pass.cpp
+../libcxx/test/std/input.output/filesystems/class.path/path.member/path.compare.pass.cpp
+../libcxx/test/std/input.output/filesystems/class.path/path.member/path.concat.pass.cpp
+../libcxx/test/std/input.output/filesystems/class.path/path.member/path.construct/move.pass.cpp
+../libcxx/test/std/input.output/filesystems/class.path/path.member/path.decompose/path.decompose.pass.cpp
+../libcxx/test/std/input.output/filesystems/class.path/path.member/path.gen/lexically_normal.pass.cpp
+../libcxx/test/std/input.output/filesystems/class.path/path.member/path.gen/lexically_relative_and_proximate.pass.cpp
+../libcxx/test/std/input.output/filesystems/class.path/path.member/path.generic.obs/generic_string_alloc.pass.cpp
+../libcxx/test/std/input.output/filesystems/class.path/path.member/path.generic.obs/named_overloads.pass.cpp
+../libcxx/test/std/input.output/filesystems/class.path/path.member/path.modifiers/clear.pass.cpp
+../libcxx/test/std/input.output/filesystems/class.path/path.member/path.modifiers/make_preferred.pass.cpp
+../libcxx/test/std/input.output/filesystems/class.path/path.member/path.modifiers/remove_filename.pass.cpp
+../libcxx/test/std/input.output/filesystems/class.path/path.member/path.modifiers/replace_extension.pass.cpp
+../libcxx/test/std/input.output/filesystems/class.path/path.member/path.modifiers/replace_filename.pass.cpp
+../libcxx/test/std/input.output/filesystems/class.path/path.member/path.modifiers/swap.pass.cpp
+../libcxx/test/std/input.output/filesystems/class.path/path.member/path.native.obs/named_overloads.pass.cpp
+../libcxx/test/std/input.output/filesystems/class.path/path.nonmember/path.factory.pass.cpp
+../libcxx/test/std/input.output/filesystems/class.path/path.nonmember/path.io.pass.cpp
+../libcxx/test/std/input.output/filesystems/class.path/path.nonmember/swap.pass.cpp
+../libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/copy_assign.pass.cpp
+../libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/copy.pass.cpp
+../libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/ctor.pass.cpp
+../libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/depth.pass.cpp
+../libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/disable_recursion_pending.pass.cpp
+../libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
+../libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/move_assign.pass.cpp
+../libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/move.pass.cpp
+../libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/pop.pass.cpp
+../libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/recursion_pending.pass.cpp
+../libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.nonmembers/begin_end.pass.cpp
+../libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.canonical/canonical.pass.cpp
+../libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.copy_file/copy_file_large.pass.cpp
+../libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.copy_file/copy_file.pass.cpp
+../libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.copy_symlink/copy_symlink.pass.cpp
+../libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.copy/copy.pass.cpp
+../libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.create_directories/create_directories.pass.cpp
+../libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.create_directory_symlink/create_directory_symlink.pass.cpp
+../libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.create_directory/create_directory_with_attributes.pass.cpp
+../libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.create_directory/create_directory.pass.cpp
+../libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.create_hard_link/create_hard_link.pass.cpp
+../libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.create_symlink/create_symlink.pass.cpp
+../libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.current_path/current_path.pass.cpp
+../libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.equivalent/equivalent.pass.cpp
+../libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.exists/exists.pass.cpp
+../libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.file_size/file_size.pass.cpp
+../libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.hard_lk_ct/hard_link_count.pass.cpp
+../libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_block_file/is_block_file.pass.cpp
+../libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_char_file/is_character_file.pass.cpp
+../libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_directory/is_directory.pass.cpp
+../libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_empty/is_empty.pass.cpp
+../libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_fifo/is_fifo.pass.cpp
+../libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_other/is_other.pass.cpp
+../libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_regular_file/is_regular_file.pass.cpp
+../libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_socket/is_socket.pass.cpp
+../libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_symlink/is_symlink.pass.cpp
+../libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
+../libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.permissions/permissions.pass.cpp
+../libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.proximate/proximate.pass.cpp
+../libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.read_symlink/read_symlink.pass.cpp
+../libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.relative/relative.pass.cpp
+../libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.remove_all/remove_all.pass.cpp
+../libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.remove_all/toctou.pass.cpp
+../libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.remove/remove.pass.cpp
+../libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.rename/rename.pass.cpp
+../libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.resize_file/resize_file.pass.cpp
+../libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.space/space.pass.cpp
+../libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.status/status.pass.cpp
+../libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.symlink_status/symlink_status.pass.cpp
+../libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.temp_dir_path/temp_directory_path.pass.cpp
+../libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.weakly_canonical/weakly_canonical.pass.cpp
+../libcxx/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.dtor/dtor.pass.cpp
+../libcxx/test/std/localization/locale.stdcvt/codecvt_utf16.pass.cpp
+../libcxx/test/std/localization/locale.stdcvt/codecvt_utf8.pass.cpp
+../libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/ctor.pass.cpp
+../libcxx/test/std/localization/locales/locale/locale.members/combine.pass.cpp
+../libcxx/test/std/strings/basic.string/string.cons/substr_rvalue.pass.cpp
+../libcxx/test/std/utilities/any/any.class/any.assign/copy.pass.cpp
+../libcxx/test/std/utilities/any/any.class/any.assign/value.pass.cpp
+../libcxx/test/std/utilities/any/any.class/any.cons/copy.pass.cpp
+../libcxx/test/std/utilities/any/any.class/any.cons/default.pass.cpp
+../libcxx/test/std/utilities/any/any.class/any.cons/in_place_type.pass.cpp
+../libcxx/test/std/utilities/any/any.class/any.cons/move.pass.cpp
+../libcxx/test/std/utilities/any/any.class/any.cons/value.pass.cpp
+../libcxx/test/std/utilities/any/any.class/any.modifiers/emplace.pass.cpp
+../libcxx/test/std/utilities/any/any.nonmembers/any.cast/any_cast_reference.pass.cpp
+../libcxx/test/std/utilities/any/any.nonmembers/make_any.pass.cpp
+../libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.alg/swap.pass.cpp
+../libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_assign.pass.cpp
+../libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_move.pass.cpp
+../libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_assign.pass.cpp
+../libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F.pass.cpp
+../libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign.pass.cpp
+../libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/swap.pass.cpp
+../libcxx/test/std/utilities/memory/default.allocator/allocator.members/allocate_at_least.pass.cpp
+../libcxx/test/std/utilities/memory/default.allocator/allocator.members/allocate.pass.cpp
+../libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp
+../libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_throw.pass.cpp
+../libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_throw.pass.cpp
+../libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_throw.pass.cpp
+../libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp
+../libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp
+../libcxx/test/std/utilities/utility/mem.res/mem.res.global/new_delete_resource.pass.cpp
+../libcxx/test/std/utilities/utility/mem.res/mem.res.global/null_memory_resource.pass.cpp
+../libcxx/test/std/utilities/utility/mem.res/mem.res.monotonic.buffer/mem.res.monotonic.buffer.ctor/without_buffer.pass.cpp
+../libcxx/test/std/utilities/utility/mem.res/mem.res.monotonic.buffer/mem.res.monotonic.buffer.mem/allocate_deallocate.pass.cpp
+../libcxx/test/std/utilities/utility/mem.res/mem.res.monotonic.buffer/mem.res.monotonic.buffer.mem/allocate_exception_safety.pass.cpp
+../libcxx/test/std/utilities/utility/mem.res/mem.res.monotonic.buffer/mem.res.monotonic.buffer.mem/allocate_from_initial_buffer.pass.cpp
+../libcxx/test/std/utilities/utility/mem.res/mem.res.monotonic.buffer/mem.res.monotonic.buffer.mem/allocate_from_zero_sized_buffer.pass.cpp
+../libcxx/test/std/utilities/utility/mem.res/mem.res.monotonic.buffer/mem.res.monotonic.buffer.mem/allocate_in_geometric_progression.pass.cpp
+../libcxx/test/std/utilities/utility/mem.res/mem.res.monotonic.buffer/mem.res.monotonic.buffer.mem/allocate_overaligned_request.pass.cpp
+../libcxx/test/std/utilities/utility/mem.res/mem.res.monotonic.buffer/mem.res.monotonic.buffer.mem/allocate_with_initial_size.pass.cpp
+../libcxx/test/std/utilities/utility/mem.res/mem.res.pool/mem.res.pool.ctor/ctor_does_not_allocate.pass.cpp
+../libcxx/test/std/utilities/utility/mem.res/mem.res.pool/mem.res.pool.mem/equality.pass.cpp
+../libcxx/test/std/utilities/utility/mem.res/mem.res.pool/mem.res.pool.mem/sync_allocate_overaligned_request.pass.cpp
+../libcxx/test/std/utilities/utility/mem.res/mem.res.pool/mem.res.pool.mem/sync_allocate_reuse_blocks.pass.cpp
+../libcxx/test/std/utilities/utility/mem.res/mem.res.pool/mem.res.pool.mem/sync_allocate.pass.cpp
+../libcxx/test/std/utilities/utility/mem.res/mem.res.pool/mem.res.pool.mem/unsync_allocate_overaligned_request.pass.cpp
+../libcxx/test/std/utilities/utility/mem.res/mem.res.pool/mem.res.pool.mem/unsync_allocate_reuse_blocks.pass.cpp
+../libcxx/test/std/utilities/utility/mem.res/mem.res.pool/mem.res.pool.mem/unsync_allocate.pass.cpp
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-2/bintools-unwrapped.nix b/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-2/bintools-unwrapped.nix
new file mode 100644
index 000000000000..ef40dd4d3824
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-2/bintools-unwrapped.nix
@@ -0,0 +1,28 @@
+{ runCommand
+, llvm
+, lld
+}:
+
+runCommand "rocm-llvm-binutils-${llvm.version}" { preferLocalBuild = true; } ''
+  mkdir -p $out/bin
+
+  for prog in ${lld}/bin/*; do
+    ln -s $prog $out/bin/$(basename $prog)
+  done
+
+  for prog in ${llvm}/bin/*; do
+    ln -sf $prog $out/bin/$(basename $prog)
+  done
+
+  ln -s ${llvm}/bin/llvm-ar $out/bin/ar
+  ln -s ${llvm}/bin/llvm-as $out/bin/as
+  ln -s ${llvm}/bin/llvm-dwp $out/bin/dwp
+  ln -s ${llvm}/bin/llvm-nm $out/bin/nm
+  ln -s ${llvm}/bin/llvm-objcopy $out/bin/objcopy
+  ln -s ${llvm}/bin/llvm-objdump $out/bin/objdump
+  ln -s ${llvm}/bin/llvm-ranlib $out/bin/ranlib
+  ln -s ${llvm}/bin/llvm-readelf $out/bin/readelf
+  ln -s ${llvm}/bin/llvm-size $out/bin/size
+  ln -s ${llvm}/bin/llvm-strip $out/bin/strip
+  ln -s ${lld}/bin/lld $out/bin/ld
+''
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-2/compiler-rt.nix b/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-2/compiler-rt.nix
new file mode 100644
index 000000000000..3b8e41705e1a
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-2/compiler-rt.nix
@@ -0,0 +1,63 @@
+{ lib
+, stdenv
+, callPackage
+, rocmUpdateScript
+, llvm
+, glibc
+}:
+
+callPackage ../base.nix rec {
+  inherit stdenv rocmUpdateScript;
+  buildDocs = false; # No documentation to build
+  buildMan = false; # No man pages to build
+  targetName = "compiler-rt";
+  targetDir = "runtimes";
+
+  targetRuntimes = [
+    "libunwind"
+    "libcxxabi"
+    "libcxx"
+    targetName
+  ];
+
+  extraCMakeFlags = [
+    "-DCOMPILER_RT_INCLUDE_TESTS=ON"
+    "-DCOMPILER_RT_USE_LLVM_UNWINDER=ON"
+    "-DCOMPILER_RT_CXX_LIBRARY=libcxx"
+    "-DCOMPILER_RT_CAN_EXECUTE_TESTS=OFF" # We can't run most of these
+
+    # Workaround having to build combined
+    "-DLIBUNWIND_INCLUDE_DOCS=OFF"
+    "-DLIBUNWIND_INCLUDE_TESTS=OFF"
+    "-DLIBUNWIND_USE_COMPILER_RT=ON"
+    "-DLIBUNWIND_INSTALL_LIBRARY=OFF"
+    "-DLIBUNWIND_INSTALL_HEADERS=OFF"
+    "-DLIBCXXABI_INCLUDE_TESTS=OFF"
+    "-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
+    "-DLIBCXXABI_USE_COMPILER_RT=ON"
+    "-DLIBCXXABI_INSTALL_LIBRARY=OFF"
+    "-DLIBCXXABI_INSTALL_HEADERS=OFF"
+    "-DLIBCXX_INCLUDE_DOCS=OFF"
+    "-DLIBCXX_INCLUDE_TESTS=OFF"
+    "-DLIBCXX_USE_COMPILER_RT=ON"
+    "-DLIBCXX_CXX_ABI=libcxxabi"
+    "-DLIBCXX_INSTALL_LIBRARY=OFF"
+    "-DLIBCXX_INSTALL_HEADERS=OFF"
+  ];
+
+  extraPostPatch = ''
+    # `No such file or directory: 'ldd'`
+    substituteInPlace ../compiler-rt/test/lit.common.cfg.py \
+      --replace "'ldd'," "'${glibc.bin}/bin/ldd',"
+
+    # We can run these
+    substituteInPlace ../compiler-rt/test/CMakeLists.txt \
+      --replace "endfunction()" "endfunction()''\nadd_subdirectory(builtins)''\nadd_subdirectory(shadowcallstack)"
+
+    # Could not launch llvm-config in /build/source/runtimes/build/bin
+    mkdir -p build/bin
+    ln -s ${llvm}/bin/llvm-config build/bin
+  '';
+
+  extraLicenses = [ lib.licenses.mit ];
+}
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-2/libc.nix b/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-2/libc.nix
new file mode 100644
index 000000000000..7e7cf9c2a608
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-2/libc.nix
@@ -0,0 +1,26 @@
+{ stdenv
+, callPackage
+, rocmUpdateScript
+}:
+
+callPackage ../base.nix rec {
+  inherit stdenv rocmUpdateScript;
+  buildMan = false; # No man pages to build
+  targetName = "libc";
+  targetDir = "runtimes";
+  targetRuntimes = [ targetName ];
+
+  extraPostPatch = ''
+    # `Failed to match ... against ...` `Match value not within tolerance value of MPFR result:`
+    # We need a better way, but I don't know enough sed magic and patching `CMakeLists.txt` isn't working...
+    substituteInPlace ../libc/test/src/math/log10_test.cpp \
+      --replace "i < N" "i < 0" \
+      --replace "test(mpfr::RoundingMode::Nearest);" "" \
+      --replace "test(mpfr::RoundingMode::Downward);" "" \
+      --replace "test(mpfr::RoundingMode::Upward);" "" \
+      --replace "test(mpfr::RoundingMode::TowardZero);" ""
+  '';
+
+  checkTargets = [ "check-${targetName}" ];
+  hardeningDisable = [ "fortify" ]; # Prevent `error: "Assumed value of MB_LEN_MAX wrong"`
+}
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-2/libcxx.nix b/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-2/libcxx.nix
new file mode 100644
index 000000000000..473227242765
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-2/libcxx.nix
@@ -0,0 +1,42 @@
+{ stdenv
+, callPackage
+, rocmUpdateScript
+}:
+
+callPackage ../base.nix rec {
+  inherit stdenv rocmUpdateScript;
+  buildMan = false; # No man pages to build
+  targetName = "libcxx";
+  targetDir = "runtimes";
+
+  targetRuntimes = [
+    "libunwind"
+    "libcxxabi"
+    targetName
+  ];
+
+  extraCMakeFlags = [
+    "-DLIBCXX_INCLUDE_DOCS=ON"
+    "-DLIBCXX_INCLUDE_TESTS=ON"
+    "-DLIBCXX_USE_COMPILER_RT=ON"
+    "-DLIBCXX_CXX_ABI=libcxxabi"
+
+    # Workaround having to build combined
+    "-DLIBUNWIND_INCLUDE_DOCS=OFF"
+    "-DLIBUNWIND_INCLUDE_TESTS=OFF"
+    "-DLIBUNWIND_USE_COMPILER_RT=ON"
+    "-DLIBUNWIND_INSTALL_LIBRARY=OFF"
+    "-DLIBUNWIND_INSTALL_HEADERS=OFF"
+    "-DLIBCXXABI_INCLUDE_TESTS=OFF"
+    "-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
+    "-DLIBCXXABI_USE_COMPILER_RT=ON"
+    "-DLIBCXXABI_INSTALL_LIBRARY=OFF"
+    "-DLIBCXXABI_INSTALL_HEADERS=OFF"
+  ];
+
+  # Most of these can't find `bash` or `mkdir`, might just be hard-coded paths, or PATH is altered
+  extraPostPatch = ''
+    chmod +w -R ../libcxx/test/{libcxx,std}
+    cat ${./1000-libcxx-failing-tests.list} | xargs -d \\n rm
+  '';
+}
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-2/libcxxabi.nix b/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-2/libcxxabi.nix
new file mode 100644
index 000000000000..e15ec777ff61
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-2/libcxxabi.nix
@@ -0,0 +1,37 @@
+{ stdenv
+, callPackage
+, rocmUpdateScript
+}:
+
+callPackage ../base.nix rec {
+  inherit stdenv rocmUpdateScript;
+  buildDocs = false; # No documentation to build
+  buildMan = false; # No man pages to build
+  targetName = "libcxxabi";
+  targetDir = "runtimes";
+
+  targetRuntimes = [
+    "libunwind"
+    targetName
+    "libcxx"
+  ];
+
+  extraCMakeFlags = [
+    "-DLIBCXXABI_INCLUDE_TESTS=ON"
+    "-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
+    "-DLIBCXXABI_USE_COMPILER_RT=ON"
+
+    # Workaround having to build combined
+    "-DLIBUNWIND_INCLUDE_DOCS=OFF"
+    "-DLIBUNWIND_INCLUDE_TESTS=OFF"
+    "-DLIBUNWIND_USE_COMPILER_RT=ON"
+    "-DLIBUNWIND_INSTALL_LIBRARY=OFF"
+    "-DLIBUNWIND_INSTALL_HEADERS=OFF"
+    "-DLIBCXX_INCLUDE_DOCS=OFF"
+    "-DLIBCXX_INCLUDE_TESTS=OFF"
+    "-DLIBCXX_USE_COMPILER_RT=ON"
+    "-DLIBCXX_CXX_ABI=libcxxabi"
+    "-DLIBCXX_INSTALL_LIBRARY=OFF"
+    "-DLIBCXX_INSTALL_HEADERS=OFF"
+  ];
+}
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-2/libunwind.nix b/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-2/libunwind.nix
new file mode 100644
index 000000000000..3d599e0d4b32
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-2/libunwind.nix
@@ -0,0 +1,26 @@
+{ stdenv
+, callPackage
+, rocmUpdateScript
+}:
+
+callPackage ../base.nix rec {
+  inherit stdenv rocmUpdateScript;
+  buildMan = false; # No man pages to build
+  targetName = "libunwind";
+  targetDir = "runtimes";
+  targetRuntimes = [ targetName ];
+
+  extraCMakeFlags = [
+    "-DLIBUNWIND_INCLUDE_DOCS=ON"
+    "-DLIBUNWIND_INCLUDE_TESTS=ON"
+    "-DLIBUNWIND_USE_COMPILER_RT=ON"
+  ];
+
+  extraPostPatch = ''
+    # `command had no output on stdout or stderr` (Says these unsupported tests)
+    chmod +w -R ../libunwind/test
+    rm ../libunwind/test/floatregister.pass.cpp
+    rm ../libunwind/test/unwind_leaffunction.pass.cpp
+    rm ../libunwind/test/libunwind_02.pass.cpp
+  '';
+}
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-2/rstdenv.nix b/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-2/rstdenv.nix
new file mode 100644
index 000000000000..45d369a6541c
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-2/rstdenv.nix
@@ -0,0 +1,35 @@
+{ stdenv
+, overrideCC
+, wrapCCWith
+, llvm
+, clang-unwrapped
+, lld
+, runtimes
+, bintools
+}:
+
+overrideCC stdenv (wrapCCWith rec {
+  inherit bintools;
+  libcxx = runtimes;
+  cc = clang-unwrapped;
+
+  extraPackages = [
+    llvm
+    lld
+  ];
+
+  nixSupport.cc-cflags = [
+    "-resource-dir=$out/resource-root"
+    "-fuse-ld=lld"
+    "-rtlib=compiler-rt"
+    "-unwindlib=libunwind"
+    "-Wno-unused-command-line-argument"
+  ];
+
+  extraBuildCommands = ''
+    clang_version=`${cc}/bin/clang -v 2>&1 | grep "clang version " | grep -E -o "[0-9.-]+"`
+    mkdir -p $out/resource-root
+    ln -s ${cc}/lib/clang/$clang_version/include $out/resource-root
+    ln -s ${runtimes}/lib $out/resource-root
+  '';
+})
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-3/0000-mlir-fix-debugtranslation.patch b/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-3/0000-mlir-fix-debugtranslation.patch
new file mode 100644
index 000000000000..f4221a088136
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-3/0000-mlir-fix-debugtranslation.patch
@@ -0,0 +1,36 @@
+From f1d1e10ec7e1061bf0b90abbc1e298d9438a5e74 Mon Sep 17 00:00:00 2001
+From: Scott Linder <Scott.Linder@amd.com>
+Date: Mon, 11 Sep 2023 18:37:37 +0000
+Subject: [PATCH] [HeterogeneousDWARF] Update MLIR DI Metadata handling
+
+Pass a default DW_MSPACE_LLVM_none to satisfy new API
+
+Change-Id: I50df461f00b5510a715f55f61107122318102d22
+---
+ lib/Target/LLVMIR/DebugTranslation.cpp | 6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/lib/Target/LLVMIR/DebugTranslation.cpp b/lib/Target/LLVMIR/DebugTranslation.cpp
+index 2053f5bcef06aa6..635ee5d7e5fefdc 100644
+--- a/lib/Target/LLVMIR/DebugTranslation.cpp
++++ b/lib/Target/LLVMIR/DebugTranslation.cpp
+@@ -148,7 +148,8 @@ llvm::DIDerivedType *DebugTranslation::translateImpl(DIDerivedTypeAttr attr) {
+       /*File=*/nullptr, /*Line=*/0,
+       /*Scope=*/nullptr, translate(attr.getBaseType()), attr.getSizeInBits(),
+       attr.getAlignInBits(), attr.getOffsetInBits(),
+-      /*DWARFAddressSpace=*/std::nullopt, /*Flags=*/llvm::DINode::FlagZero);
++      /*DWARFAddressSpace=*/std::nullopt, llvm::dwarf::DW_MSPACE_LLVM_none,
++      /*Flags=*/llvm::DINode::FlagZero);
+ }
+ 
+ llvm::DIFile *DebugTranslation::translateImpl(DIFileAttr attr) {
+@@ -185,7 +186,8 @@ DebugTranslation::translateImpl(DILocalVariableAttr attr) {
+       llvmCtx, translate(attr.getScope()), getMDStringOrNull(attr.getName()),
+       translate(attr.getFile()), attr.getLine(), translate(attr.getType()),
+       attr.getArg(),
+-      /*Flags=*/llvm::DINode::FlagZero, attr.getAlignInBits(),
++      /*Flags=*/llvm::DINode::FlagZero, llvm::dwarf::DW_MSPACE_LLVM_none,
++      attr.getAlignInBits(),
+       /*Annotations=*/nullptr);
+ }
+ 
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-3/1000-openmp-failing-tests.list b/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-3/1000-openmp-failing-tests.list
new file mode 100644
index 000000000000..e53b21b3c535
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-3/1000-openmp-failing-tests.list
@@ -0,0 +1,122 @@
+runtime/test/tasking/hidden_helper_task/gtid.cpp
+runtime/test/ompt/parallel/parallel_if0.c
+runtime/test/ompt/parallel/serialized.c
+runtime/test/ompt/teams/parallel_team.c
+runtime/test/ompt/teams/serial_teams.c
+runtime/test/ompt/teams/serialized.c
+runtime/test/ompt/teams/team.c
+libomptarget/test/api/assert.c
+libomptarget/test/api/omp_device_managed_memory.c
+libomptarget/test/api/omp_device_memory.c
+libomptarget/test/api/omp_get_device_num.c
+libomptarget/test/api/omp_host_pinned_memory.c
+libomptarget/test/api/omp_host_pinned_memory_alloc.c
+libomptarget/test/api/omp_target_memcpy_async1.c
+libomptarget/test/api/omp_target_memcpy_async2.c
+libomptarget/test/api/omp_target_memcpy_rect_async1.c
+libomptarget/test/api/omp_target_memcpy_rect_async2.c
+libomptarget/test/mapping/array_section_implicit_capture.c
+libomptarget/test/mapping/data_absent_at_exit.c
+libomptarget/test/mapping/data_member_ref.cpp
+libomptarget/test/mapping/declare_mapper_api.cpp
+libomptarget/test/mapping/declare_mapper_target.cpp
+libomptarget/test/mapping/declare_mapper_target_data.cpp
+libomptarget/test/mapping/declare_mapper_target_data_enter_exit.cpp
+libomptarget/test/mapping/firstprivate_aligned.cpp
+libomptarget/test/mapping/has_device_addr.cpp
+libomptarget/test/mapping/implicit_device_ptr.c
+libomptarget/test/mapping/is_device_ptr.cpp
+libomptarget/test/mapping/lambda_mapping.cpp
+libomptarget/test/mapping/low_alignment.c
+libomptarget/test/mapping/map_back_race.cpp
+libomptarget/test/mapping/power_of_two_alignment.c
+libomptarget/test/mapping/pr38704.c
+libomptarget/test/mapping/prelock.cpp
+libomptarget/test/mapping/present/target_data_at_exit.c
+libomptarget/test/mapping/private_mapping.c
+libomptarget/test/mapping/ptr_and_obj_motion.c
+libomptarget/test/mapping/reduction_implicit_map.cpp
+libomptarget/test/mapping/target_derefence_array_pointrs.cpp
+libomptarget/test/mapping/target_map_for_member_data.cpp
+libomptarget/test/mapping/target_update_array_extension.c
+libomptarget/test/mapping/target_use_device_addr.c
+libomptarget/test/offloading/atomic-compare-signedness.c
+libomptarget/test/offloading/bug47654.cpp
+libomptarget/test/offloading/bug49021.cpp
+libomptarget/test/offloading/bug49779.cpp
+libomptarget/test/offloading/bug50022.cpp
+libomptarget/test/offloading/bug51781.c
+libomptarget/test/offloading/bug51982.c
+libomptarget/test/offloading/bug53727.cpp
+libomptarget/test/offloading/complex_reduction.cpp
+libomptarget/test/offloading/cuda_no_devices.c
+libomptarget/test/offloading/d2d_memcpy.c
+libomptarget/test/offloading/dynamic_module.c
+libomptarget/test/offloading/dynamic_module_load.c
+libomptarget/test/offloading/global_constructor.cpp
+libomptarget/test/offloading/lone_target_exit_data.c
+libomptarget/test/offloading/memory_manager.cpp
+libomptarget/test/offloading/parallel_offloading_map.cpp
+libomptarget/test/offloading/static_linking.c
+libomptarget/test/offloading/std_complex_arithmetic.cpp
+libomptarget/test/offloading/target-teams-atomic.c
+libomptarget/test/offloading/target_constexpr_mapping.cpp
+libomptarget/test/offloading/target_critical_region.cpp
+libomptarget/test/offloading/target_depend_nowait.cpp
+libomptarget/test/offloading/target_nowait_target.cpp
+libomptarget/test/offloading/taskloop_offload_nowait.cpp
+libomptarget/test/offloading/test_libc.cpp
+libomptarget/test/ompt/veccopy.c
+libomptarget/test/ompt/veccopy_disallow_both.c
+libomptarget/test/ompt/veccopy_emi.c
+libomptarget/test/ompt/veccopy_emi_map.c
+libomptarget/test/ompt/veccopy_map.c
+libomptarget/test/ompt/veccopy_no_device_init.c
+libomptarget/test/ompt/veccopy_wrong_return.c
+libomptarget/test/api/is_initial_device.c
+libomptarget/test/mapping/declare_mapper_nested_default_mappers_array_subscript.cpp
+libomptarget/test/mapping/declare_mapper_nested_default_mappers_ptr_subscript.cpp
+libomptarget/test/mapping/declare_mapper_nested_default_mappers_var.cpp
+libomptarget/test/mapping/target_pointers_members_map.cpp
+libomptarget/test/api/omp_dynamic_shared_memory_mixed.c
+libomptarget/test/api/omp_env_vars.c
+libomptarget/test/api/omp_get_mapped_ptr.c
+libomptarget/test/api/omp_get_num_devices.c
+libomptarget/test/api/omp_get_num_devices_with_empty_target.c
+libomptarget/test/mapping/alloc_fail.c
+libomptarget/test/mapping/array_section_use_device_ptr.c
+libomptarget/test/mapping/declare_mapper_nested_default_mappers.cpp
+libomptarget/test/mapping/declare_mapper_nested_mappers.cpp
+libomptarget/test/mapping/declare_mapper_target_update.cpp
+libomptarget/test/mapping/delete_inf_refcount.c
+libomptarget/test/mapping/lambda_by_value.cpp
+libomptarget/test/mapping/ompx_hold/omp_target_disassociate_ptr.c
+libomptarget/test/mapping/ompx_hold/struct.c
+libomptarget/test/mapping/ompx_hold/target-data.c
+libomptarget/test/mapping/ompx_hold/target.c
+libomptarget/test/mapping/present/target.c
+libomptarget/test/mapping/present/target_array_extension.c
+libomptarget/test/mapping/present/target_data.c
+libomptarget/test/mapping/present/target_data_array_extension.c
+libomptarget/test/mapping/present/target_enter_data.c
+libomptarget/test/mapping/present/target_exit_data_delete.c
+libomptarget/test/mapping/present/target_exit_data_release.c
+libomptarget/test/mapping/present/target_update.c
+libomptarget/test/mapping/present/target_update_array_extension.c
+libomptarget/test/mapping/present/zero_length_array_section.c
+libomptarget/test/mapping/present/zero_length_array_section_exit.c
+libomptarget/test/mapping/target_data_array_extension_at_exit.c
+libomptarget/test/mapping/target_has_device_addr.c
+libomptarget/test/mapping/target_implicit_partial_map.c
+libomptarget/test/mapping/target_wrong_use_device_addr.c
+libomptarget/test/offloading/host_as_target.c
+libomptarget/test/offloading/info.c
+libomptarget/test/offloading/offloading_success.c
+libomptarget/test/offloading/offloading_success.cpp
+libomptarget/test/offloading/wtime.c
+libomptarget/test/unified_shared_memory/api.c
+libomptarget/test/unified_shared_memory/associate_ptr.c
+libomptarget/test/unified_shared_memory/close_enter_exit.c
+libomptarget/test/unified_shared_memory/close_manual.c
+libomptarget/test/unified_shared_memory/close_member.c
+libomptarget/test/unified_shared_memory/close_modifier.c
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-3/1001-mlir-failing-tests.list b/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-3/1001-mlir-failing-tests.list
new file mode 100644
index 000000000000..0b3d2d22592d
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-3/1001-mlir-failing-tests.list
@@ -0,0 +1,11 @@
+./test/Target/LLVMIR/openmp-llvm.mlir
+./test/mlir-spirv-cpu-runner/double.mlir
+./test/mlir-spirv-cpu-runner/simple_add.mlir
+./test/mlir-vulkan-runner/addf.mlir
+./test/mlir-vulkan-runner/addi.mlir
+./test/mlir-vulkan-runner/addi8.mlir
+./test/mlir-vulkan-runner/mulf.mlir
+./test/mlir-vulkan-runner/smul_extended.mlir
+./test/mlir-vulkan-runner/subf.mlir
+./test/mlir-vulkan-runner/time.mlir
+./test/mlir-vulkan-runner/umul_extended.mlir
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-3/clang-tools-extra.nix b/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-3/clang-tools-extra.nix
new file mode 100644
index 000000000000..d18673ecb3db
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-3/clang-tools-extra.nix
@@ -0,0 +1,42 @@
+{ stdenv
+, callPackage
+, rocmUpdateScript
+, llvm
+, clang-unwrapped
+, gtest
+}:
+
+callPackage ../base.nix rec {
+  inherit stdenv rocmUpdateScript;
+  buildTests = false; # `invalid operands to binary expression ('std::basic_stringstream<char>' and 'const llvm::StringRef')`
+  targetName = "clang-tools-extra";
+
+  targetProjects = [
+    "clang"
+    "clang-tools-extra"
+  ];
+
+  extraBuildInputs = [ gtest ];
+
+  extraCMakeFlags = [
+    "-DLLVM_INCLUDE_DOCS=OFF"
+    "-DLLVM_INCLUDE_TESTS=OFF"
+    "-DCLANG_INCLUDE_DOCS=OFF"
+    "-DCLANG_INCLUDE_TESTS=ON"
+    "-DCLANG_TOOLS_EXTRA_INCLUDE_DOCS=ON"
+  ];
+
+  extraPostInstall = ''
+    # Remove LLVM and Clang
+    for path in `find ${llvm} ${clang-unwrapped}`; do
+      if [ $path != ${llvm} ] && [ $path != ${clang-unwrapped} ]; then
+        rm -f $out''${path#${llvm}} $out''${path#${clang-unwrapped}} || true
+      fi
+    done
+
+    # Cleanup empty directories
+    find $out -type d -empty -delete
+  '';
+
+  requiredSystemFeatures = [ "big-parallel" ];
+}
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-3/clang.nix b/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-3/clang.nix
new file mode 100644
index 000000000000..91f34265f85f
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-3/clang.nix
@@ -0,0 +1,73 @@
+{ stdenv
+, wrapCCWith
+, llvm
+, lld
+, clang-unwrapped
+, bintools
+, libc
+, libunwind
+, libcxxabi
+, libcxx
+, compiler-rt
+}:
+
+wrapCCWith rec {
+  inherit libcxx bintools;
+
+  # We do this to avoid HIP pathing problems, and mimic a monolithic install
+  cc = stdenv.mkDerivation (finalAttrs: {
+    inherit (clang-unwrapped) version;
+    pname = "rocm-llvm-clang";
+    dontUnpack = true;
+
+    installPhase = ''
+      runHook preInstall
+
+      clang_version=`${clang-unwrapped}/bin/clang -v 2>&1 | grep "clang version " | grep -E -o "[0-9.-]+"`
+      mkdir -p $out/{bin,include/c++/v1,lib/{cmake,clang/$clang_version/{include,lib}},libexec,share}
+
+      for path in ${llvm} ${clang-unwrapped} ${lld} ${libc} ${libunwind} ${libcxxabi} ${libcxx} ${compiler-rt}; do
+        cp -as $path/* $out
+        chmod +w $out/{*,include/c++/v1,lib/{clang/$clang_version/include,cmake}}
+        rm -f $out/lib/libc++.so
+      done
+
+      ln -s $out/lib/* $out/lib/clang/$clang_version/lib
+      ln -sf $out/include/* $out/lib/clang/$clang_version/include
+
+      runHook postInstall
+    '';
+
+    passthru.isClang = true;
+  });
+
+  extraPackages = [
+    llvm
+    lld
+    libc
+    libunwind
+    libcxxabi
+    compiler-rt
+  ];
+
+  nixSupport.cc-cflags = [
+    "-resource-dir=$out/resource-root"
+    "-fuse-ld=lld"
+    "-rtlib=compiler-rt"
+    "-unwindlib=libunwind"
+    "-Wno-unused-command-line-argument"
+  ];
+
+  extraBuildCommands = ''
+    clang_version=`${cc}/bin/clang -v 2>&1 | grep "clang version " | grep -E -o "[0-9.-]+"`
+    mkdir -p $out/resource-root
+    ln -s ${cc}/lib/clang/$clang_version/{include,lib} $out/resource-root
+
+    # Not sure why, but hardening seems to make things break
+    echo "" > $out/nix-support/add-hardening.sh
+
+    # GPU compilation uses builtin `lld`
+    substituteInPlace $out/bin/{clang,clang++} \
+      --replace "-MM) dontLink=1 ;;" "-MM | --cuda-device-only) dontLink=1 ;;''\n--cuda-host-only | --cuda-compile-host-device) dontLink=0 ;;"
+  '';
+}
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-3/flang.nix b/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-3/flang.nix
new file mode 100644
index 000000000000..421663dcb1b7
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-3/flang.nix
@@ -0,0 +1,31 @@
+{ stdenv
+, callPackage
+, rocmUpdateScript
+, clang-unwrapped
+, mlir
+, graphviz
+, python3Packages
+}:
+
+callPackage ../base.nix rec {
+  inherit stdenv rocmUpdateScript;
+  targetName = "flang";
+  targetDir = targetName;
+
+  extraNativeBuildInputs = [
+    graphviz
+    python3Packages.sphinx-markdown-tables
+  ];
+
+  extraBuildInputs = [ mlir ];
+
+  extraCMakeFlags = [
+    "-DCLANG_DIR=${clang-unwrapped}/lib/cmake/clang"
+    "-DMLIR_TABLEGEN_EXE=${mlir}/bin/mlir-tblgen"
+    "-DCLANG_TABLEGEN_EXE=${clang-unwrapped}/bin/clang-tblgen"
+    "-DFLANG_INCLUDE_TESTS=OFF" # `The dependency target "Bye" of target ...`
+  ];
+
+  # `flang/lib/Semantics/check-omp-structure.cpp:1905:1: error: no member named 'v' in 'Fortran::parser::OmpClause::OmpxDynCgroupMem'`
+  isBroken = true;
+}
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-3/libclc.nix b/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-3/libclc.nix
new file mode 100644
index 000000000000..1fd72ee67188
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-3/libclc.nix
@@ -0,0 +1,36 @@
+{ stdenv
+, callPackage
+, rocmUpdateScript
+, llvm
+, clang
+, spirv-llvm-translator
+}:
+
+let
+  spirv = (spirv-llvm-translator.override { inherit llvm; });
+in callPackage ../base.nix rec {
+  inherit stdenv rocmUpdateScript;
+  buildDocs = false; # No documentation to build
+  buildMan = false; # No man pages to build
+  targetName = "libclc";
+  targetDir = targetName;
+  extraBuildInputs = [ spirv ];
+
+  # `spirv-mesa3d` isn't compiling with LLVM 15.0.0, it does with LLVM 14.0.0
+  # Try removing the `spirv-mesa3d` and `clspv` patches next update
+  # `clspv` tests fail, unresolved calls
+  extraPostPatch = ''
+    substituteInPlace CMakeLists.txt \
+      --replace "find_program( LLVM_CLANG clang PATHS \''${LLVM_BINDIR} NO_DEFAULT_PATH )" \
+        "find_program( LLVM_CLANG clang PATHS \"${clang}/bin\" NO_DEFAULT_PATH )" \
+      --replace "find_program( LLVM_SPIRV llvm-spirv PATHS \''${LLVM_BINDIR} NO_DEFAULT_PATH )" \
+        "find_program( LLVM_SPIRV llvm-spirv PATHS \"${spirv}/bin\" NO_DEFAULT_PATH )" \
+      --replace "  spirv-mesa3d-" "" \
+      --replace "  spirv64-mesa3d-" "" \
+      --replace "NOT \''${t} MATCHES" \
+        "NOT \''${ARCH} STREQUAL \"clspv\" AND NOT \''${ARCH} STREQUAL \"clspv64\" AND NOT \''${t} MATCHES"
+  '';
+
+  checkTargets = [ ];
+  isBroken = true; # ROCm 5.7.0 doesn't have IR/AttributeMask.h yet...?
+}
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-3/lldb.nix b/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-3/lldb.nix
new file mode 100644
index 000000000000..9b7d25e06d9d
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-3/lldb.nix
@@ -0,0 +1,39 @@
+{ stdenv
+, callPackage
+, rocmUpdateScript
+, clang
+, xz
+, swig
+, lua5_3
+, graphviz
+, gtest
+, python3Packages
+}:
+
+callPackage ../base.nix rec {
+  inherit stdenv rocmUpdateScript;
+  buildTests = false; # FIXME: Bad pathing for clang executable in tests, using relative path most likely
+  targetName = "lldb";
+  targetDir = targetName;
+  extraNativeBuildInputs = [ python3Packages.sphinx-automodapi ];
+
+  extraBuildInputs = [
+    xz
+    swig
+    lua5_3
+    graphviz
+    gtest
+  ];
+
+  extraCMakeFlags = [
+    "-DLLDB_EXTERNAL_CLANG_RESOURCE_DIR=${clang}/resource-root/lib/clang/$clang_version"
+    "-DLLDB_INCLUDE_TESTS=ON"
+    "-DLLDB_INCLUDE_UNITTESTS=ON"
+  ];
+
+  extraPostPatch = ''
+    export clang_version=`clang -v 2>&1 | grep "clang version " | grep -E -o "[0-9.-]+"`
+  '';
+
+  checkTargets = [ "check-${targetName}" ];
+}
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-3/mlir.nix b/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-3/mlir.nix
new file mode 100644
index 000000000000..1b0bc29ea62b
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-3/mlir.nix
@@ -0,0 +1,57 @@
+{ stdenv
+, callPackage
+, rocmUpdateScript
+, clr
+, vulkan-headers
+, vulkan-loader
+, glslang
+, shaderc
+, lit
+}:
+
+callPackage ../base.nix rec {
+  inherit stdenv rocmUpdateScript;
+  buildDocs = false; # No decent way to hack this to work
+  buildMan = false; # No man pages to build
+  targetName = "mlir";
+  targetDir = targetName;
+
+  # Fix `DebugTranslation.cpp:139:10: error: no matching function for call to 'get'`
+  # We patch at a different source root, so we modify the patch and include it locally
+  # https://github.com/RadeonOpenCompute/llvm-project/commit/f1d1e10ec7e1061bf0b90abbc1e298d9438a5e74.patch
+  extraPatches = [ ./0000-mlir-fix-debugtranslation.patch ];
+  extraNativeBuildInputs = [ clr ];
+
+  extraBuildInputs = [
+    vulkan-headers
+    vulkan-loader
+    glslang
+    shaderc
+  ];
+
+  extraCMakeFlags = [
+    "-DMLIR_INCLUDE_DOCS=ON"
+    "-DMLIR_INCLUDE_TESTS=ON"
+    "-DMLIR_ENABLE_ROCM_RUNNER=ON"
+    "-DMLIR_ENABLE_SPIRV_CPU_RUNNER=ON"
+    "-DMLIR_ENABLE_VULKAN_RUNNER=ON"
+    "-DROCM_TEST_CHIPSET=gfx000" # CPU runner
+  ];
+
+  extraPostPatch = ''
+    # `add_library cannot create target "llvm_gtest" because an imported target with the same name already exists`
+    substituteInPlace CMakeLists.txt \
+      --replace "EXISTS \''${UNITTEST_DIR}/googletest/include/gtest/gtest.h" "FALSE"
+
+    # Mainly `No such file or directory`
+    cat ${./1001-mlir-failing-tests.list} | xargs -d \\n rm
+  '';
+
+  extraPostInstall = ''
+    mkdir -p $out/bin
+    mv bin/mlir-tblgen $out/bin
+  '';
+
+  checkTargets = [ "check-${targetName}" ];
+  requiredSystemFeatures = [ "big-parallel" ];
+}
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-3/openmp.nix b/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-3/openmp.nix
new file mode 100644
index 000000000000..5fd7b6fd9aa3
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-3/openmp.nix
@@ -0,0 +1,54 @@
+{ lib
+, stdenv
+, callPackage
+, rocmUpdateScript
+, llvm
+, clang
+, clang-unwrapped
+, rocm-device-libs
+, rocm-runtime
+, rocm-thunk
+, perl
+, elfutils
+, libdrm
+, numactl
+, lit
+}:
+
+callPackage ../base.nix rec {
+  inherit stdenv rocmUpdateScript;
+  targetName = "openmp";
+  targetDir = targetName;
+  extraNativeBuildInputs = [ perl ];
+
+  extraBuildInputs = [
+    rocm-device-libs
+    rocm-runtime
+    rocm-thunk
+    elfutils
+    libdrm
+    numactl
+  ];
+
+  extraCMakeFlags = [
+    "-DCMAKE_MODULE_PATH=/build/source/llvm/cmake/modules" # For docs
+    "-DCLANG_TOOL=${clang}/bin/clang"
+    "-DCLANG_OFFLOAD_BUNDLER_TOOL=${clang-unwrapped}/bin/clang-offload-bundler"
+    "-DPACKAGER_TOOL=${clang-unwrapped}/bin/clang-offload-packager"
+    "-DOPENMP_LLVM_TOOLS_DIR=${llvm}/bin"
+    "-DOPENMP_LLVM_LIT_EXECUTABLE=${lit}/bin/.lit-wrapped"
+    "-DDEVICELIBS_ROOT=${rocm-device-libs.src}"
+  ];
+
+  extraPostPatch = ''
+    # We can't build this target at the moment
+    substituteInPlace libomptarget/DeviceRTL/CMakeLists.txt \
+      --replace "gfx1010" ""
+
+    # No idea what's going on here...
+    cat ${./1000-openmp-failing-tests.list} | xargs -d \\n rm
+  '';
+
+  checkTargets = [ "check-${targetName}" ];
+  extraLicenses = [ lib.licenses.mit ];
+}
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-3/polly.nix b/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-3/polly.nix
new file mode 100644
index 000000000000..e001f33dfd43
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-3/polly.nix
@@ -0,0 +1,18 @@
+{ stdenv
+, callPackage
+, rocmUpdateScript
+}:
+
+callPackage ../base.nix rec {
+  inherit stdenv rocmUpdateScript;
+  targetName = "polly";
+  targetDir = targetName;
+
+  extraPostPatch = ''
+    # `add_library cannot create target "llvm_gtest" because an imported target with the same name already exists`
+    substituteInPlace CMakeLists.txt \
+      --replace "NOT TARGET gtest" "FALSE"
+  '';
+
+  checkTargets = [ "check-${targetName}" ];
+}
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-3/pstl.nix b/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-3/pstl.nix
new file mode 100644
index 000000000000..dc7d7cd6ccbf
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/llvm/stage-3/pstl.nix
@@ -0,0 +1,15 @@
+{ stdenv
+, callPackage
+, rocmUpdateScript
+}:
+
+callPackage ../base.nix rec {
+  inherit stdenv rocmUpdateScript;
+  buildDocs = false; # No documentation to build
+  buildMan = false; # No man pages to build
+  buildTests = false; # Too many errors
+  targetName = "pstl";
+  targetDir = "runtimes";
+  targetRuntimes = [ targetName ];
+  checkTargets = [ "check-${targetName}" ];
+}
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/migraphx/default.nix b/nixpkgs/pkgs/development/rocm-modules/5/migraphx/default.nix
new file mode 100644
index 000000000000..5842cd1695d5
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/migraphx/default.nix
@@ -0,0 +1,172 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, rocmUpdateScript
+, pkg-config
+, cmake
+, rocm-cmake
+, clr
+, clang-tools-extra
+, openmp
+, rocblas
+, rocmlir
+, composable_kernel
+, miopengemm
+, miopen
+, protobuf
+, half
+, nlohmann_json
+, msgpack
+, sqlite
+, oneDNN_2
+, blaze
+, cppcheck
+, rocm-device-libs
+, texlive
+, doxygen
+, sphinx
+, docutils
+, ghostscript
+, python3Packages
+, buildDocs ? false
+, buildTests ? false
+}:
+
+let
+  latex = lib.optionalAttrs buildDocs texlive.combine {
+    inherit (texlive) scheme-small
+    latexmk
+    tex-gyre
+    fncychap
+    wrapfig
+    capt-of
+    framed
+    needspace
+    tabulary
+    varwidth
+    titlesec
+    epstopdf;
+  };
+in stdenv.mkDerivation (finalAttrs: {
+  pname = "migraphx";
+  version = "5.7.0";
+
+  outputs = [
+    "out"
+  ] ++ lib.optionals buildDocs [
+    "doc"
+  ] ++ lib.optionals buildTests [
+    "test"
+  ];
+
+  src = fetchFromGitHub {
+    owner = "ROCmSoftwarePlatform";
+    repo = "AMDMIGraphX";
+    rev = "rocm-${finalAttrs.version}";
+    hash = "sha256-7yL7Zn5I8GUPIAgB7tVLZI7OEHLv0E4FcLVx9xMfsNY=";
+  };
+
+  nativeBuildInputs = [
+    pkg-config
+    cmake
+    rocm-cmake
+    clr
+    clang-tools-extra
+    python3Packages.python
+  ] ++ lib.optionals buildDocs [
+    latex
+    doxygen
+    sphinx
+    docutils
+    ghostscript
+    python3Packages.sphinx-rtd-theme
+    python3Packages.breathe
+  ];
+
+  buildInputs = [
+    openmp
+    rocblas
+    rocmlir
+    composable_kernel
+    miopengemm
+    miopen
+    protobuf
+    half
+    nlohmann_json
+    msgpack
+    sqlite
+    oneDNN_2
+    blaze
+    cppcheck
+    python3Packages.pybind11
+    python3Packages.onnx
+  ];
+
+  cmakeFlags = [
+    "-DMIGRAPHX_ENABLE_GPU=ON"
+    "-DMIGRAPHX_ENABLE_CPU=ON"
+    "-DMIGRAPHX_ENABLE_FPGA=ON"
+    "-DMIGRAPHX_ENABLE_MLIR=OFF" # LLVM or rocMLIR mismatch?
+    # Manually define CMAKE_INSTALL_<DIR>
+    # See: https://github.com/NixOS/nixpkgs/pull/197838
+    "-DCMAKE_INSTALL_BINDIR=bin"
+    "-DCMAKE_INSTALL_LIBDIR=lib"
+    "-DCMAKE_INSTALL_INCLUDEDIR=include"
+  ];
+
+  postPatch = ''
+    # We need to not use hipcc and define the CXXFLAGS manually due to `undefined hidden symbol: tensorflow:: ...`
+    export CXXFLAGS+="--rocm-path=${clr} --rocm-device-lib-path=${rocm-device-libs}/amdgcn/bitcode"
+    patchShebangs tools
+
+    # `error: '__clang_hip_runtime_wrapper.h' file not found [clang-diagnostic-error]`
+    substituteInPlace CMakeLists.txt \
+      --replace "set(MIGRAPHX_TIDY_ERRORS ALL)" ""
+
+    # JIT library was removed from composable_kernel...
+    # https://github.com/ROCmSoftwarePlatform/composable_kernel/issues/782
+    substituteInPlace src/targets/gpu/CMakeLists.txt \
+      --replace " COMPONENTS jit_library" "" \
+      --replace " composable_kernel::jit_library" "" \
+      --replace "if(WIN32)" "if(TRUE)"
+  '' + lib.optionalString (!buildDocs) ''
+    substituteInPlace CMakeLists.txt \
+      --replace "add_subdirectory(doc)" ""
+  '' + lib.optionalString (!buildTests) ''
+    substituteInPlace CMakeLists.txt \
+      --replace "add_subdirectory(test)" ""
+  '';
+
+  # Unfortunately, it seems like we have to call make on this manually
+  preInstall = lib.optionalString buildDocs ''
+    export HOME=$(mktemp -d)
+    make -j$NIX_BUILD_CORES doc
+    cd ../doc/pdf
+    make -j$NIX_BUILD_CORES
+    cd -
+  '';
+
+  postInstall = lib.optionalString buildDocs ''
+    mv ../doc/html $out/share/doc/migraphx
+    mv ../doc/pdf/MIGraphX.pdf $out/share/doc/migraphx
+  '' + lib.optionalString buildTests ''
+    mkdir -p $test/bin
+    mv bin/test_* $test/bin
+    patchelf $test/bin/test_* --shrink-rpath --allowed-rpath-prefixes "$NIX_STORE"
+  '';
+
+  passthru.updateScript = rocmUpdateScript {
+    name = finalAttrs.pname;
+    owner = finalAttrs.src.owner;
+    repo = finalAttrs.src.repo;
+  };
+
+  meta = with lib; {
+    description = "AMD's graph optimization engine";
+    homepage = "https://github.com/ROCmSoftwarePlatform/AMDMIGraphX";
+    license = with licenses; [ mit ];
+    maintainers = teams.rocm.members;
+    platforms = platforms.linux;
+    broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
+  };
+})
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/miopen/default.nix b/nixpkgs/pkgs/development/rocm-modules/5/miopen/default.nix
new file mode 100644
index 000000000000..d22518aa51c6
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/miopen/default.nix
@@ -0,0 +1,240 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, fetchpatch
+, rocmUpdateScript
+, runCommand
+, pkg-config
+, cmake
+, rocm-cmake
+, rocblas
+, rocmlir
+, clr
+, clang-tools-extra
+, clang-ocl
+, miopengemm
+, composable_kernel
+, frugally-deep
+, rocm-docs-core
+, half
+, boost
+, sqlite
+, bzip2
+, lbzip2
+, nlohmann_json
+, texlive
+, doxygen
+, sphinx
+, zlib
+, gtest
+, rocm-comgr
+, python3Packages
+, buildDocs ? false # Needs internet because of rocm-docs-core
+, buildTests ? false
+, useOpenCL ? false
+}:
+
+let
+  version = "5.7.0";
+
+  src = fetchFromGitHub {
+    owner = "ROCmSoftwarePlatform";
+    repo = "MIOpen";
+    rev = "rocm-${version}";
+    hash = "sha256-xcKmFI8HcRA9bbh6EQGElKykIQ3RJX/q5f4IxXvM1Is=";
+    fetchLFS = true;
+    leaveDotGit = true;
+
+    # If you're reading this, it's gonna take a bit of time.
+    # fetchSubModules doesn't work with postFetch???
+    # fetchLFS isn't actually fetching the LFS files...
+    postFetch = ''
+      export HOME=$(mktemp -d)
+      cd $out
+
+      # We need more history to fetch LFS files
+      git remote add origin $url
+      git fetch origin
+      git clean -fdx
+      git checkout rocm-${version}
+
+      # We need to do this manually since using leaveDotGit and fetchSubmodules errors
+      git submodule update --init
+
+      # Fetch the LFS files
+      git lfs install
+      git lfs fetch --all
+      git lfs checkout
+
+      # Remove the defunct .git folder
+      rm -rf .git
+    '';
+  };
+
+  latex = lib.optionalAttrs buildDocs texlive.combine {
+    inherit (texlive) scheme-small
+    latexmk
+    tex-gyre
+    fncychap
+    wrapfig
+    capt-of
+    framed
+    needspace
+    tabulary
+    varwidth
+    titlesec;
+  };
+
+  gfx900 = runCommand "miopen-gfx900.kdb" { preferLocalBuild = true; } ''
+    ${lbzip2}/bin/lbzip2 -ckd ${src}/src/kernels/gfx900.kdb.bz2 > $out
+  '';
+
+  gfx906 = runCommand "miopen-gfx906.kdb" { preferLocalBuild = true; } ''
+    ${lbzip2}/bin/lbzip2 -ckd ${src}/src/kernels/gfx906.kdb.bz2 > $out
+  '';
+
+  gfx908 = runCommand "miopen-gfx908.kdb" { preferLocalBuild = true; } ''
+    ${lbzip2}/bin/lbzip2 -ckd ${src}/src/kernels/gfx908.kdb.bz2 > $out
+  '';
+
+  gfx90a = runCommand "miopen-gfx90a.kdb" { preferLocalBuild = true; } ''
+    ${lbzip2}/bin/lbzip2 -ckd ${src}/src/kernels/gfx90a.kdb.bz2 > $out
+  '';
+
+  gfx1030 = runCommand "miopen-gfx1030.kdb" { preferLocalBuild = true; } ''
+    ${lbzip2}/bin/lbzip2 -ckd ${src}/src/kernels/gfx1030.kdb.bz2 > $out
+  '';
+in stdenv.mkDerivation (finalAttrs: {
+  inherit version src;
+  pname = "miopen";
+
+  # Find zstd and add to target. Mainly for torch.
+  patches = [
+    (fetchpatch {
+      url = "https://github.com/ROCmSoftwarePlatform/MIOpen/commit/e608b4325646afeabb5e52846997b926d2019d19.patch";
+      hash = "sha256-oxa3qlIC2bzbwGxrQOZXoY/S7CpLsMrnWRB7Og0tk0M=";
+    })
+    (fetchpatch {
+      url = "https://github.com/ROCmSoftwarePlatform/MIOpen/commit/3413d2daaeb44b7d6eadcc03033a5954a118491e.patch";
+      hash = "sha256-ST4snUcTmmSI1Ogx815KEX9GdMnmubsavDzXCGJkiKs=";
+    })
+  ];
+
+  outputs = [
+    "out"
+  ] ++ lib.optionals buildDocs [
+    "doc"
+  ] ++ lib.optionals buildTests [
+    "test"
+  ];
+
+  nativeBuildInputs = [
+    pkg-config
+    cmake
+    rocm-cmake
+    clr
+    clang-tools-extra
+  ];
+
+  buildInputs = [
+    rocblas
+    rocmlir
+    clang-ocl
+    miopengemm
+    composable_kernel
+    half
+    boost
+    sqlite
+    bzip2
+    nlohmann_json
+    frugally-deep
+  ] ++ lib.optionals buildDocs [
+    latex
+    doxygen
+    sphinx
+    rocm-docs-core
+    python3Packages.sphinx-rtd-theme
+    python3Packages.breathe
+    python3Packages.myst-parser
+  ] ++ lib.optionals buildTests [
+    zlib
+  ];
+
+  cmakeFlags = [
+    "-DCMAKE_CXX_FLAGS=-Wno-#warnings" # <half> -> <half/half.hpp>
+    "-DMIOPEN_USE_MIOPENGEMM=ON"
+    "-DUNZIPPER=${bzip2}/bin/bunzip2"
+    # Manually define CMAKE_INSTALL_<DIR>
+    # See: https://github.com/NixOS/nixpkgs/pull/197838
+    "-DCMAKE_INSTALL_BINDIR=bin"
+    "-DCMAKE_INSTALL_LIBDIR=lib"
+    "-DCMAKE_INSTALL_INCLUDEDIR=include"
+  ] ++ lib.optionals (!useOpenCL) [
+    "-DCMAKE_C_COMPILER=hipcc"
+    "-DCMAKE_CXX_COMPILER=hipcc"
+    "-DMIOPEN_BACKEND=HIP"
+  ] ++ lib.optionals useOpenCL [
+    "-DMIOPEN_BACKEND=OpenCL"
+  ] ++ lib.optionals buildTests [
+    "-DBUILD_TESTS=ON"
+    "-DMIOPEN_TEST_ALL=ON"
+  ];
+
+  postPatch = ''
+    patchShebangs test src/composable_kernel fin utils install_deps.cmake
+
+    substituteInPlace CMakeLists.txt \
+      --replace "unpack_db(\"\''${CMAKE_SOURCE_DIR}/src/kernels/\''${FILE_NAME}.kdb.bz2\")" "" \
+      --replace "MIOPEN_HIP_COMPILER MATCHES \".*clang\\\\+\\\\+$\"" "true" \
+      --replace "set(MIOPEN_TIDY_ERRORS ALL)" "" # error: missing required key 'key'
+
+    substituteInPlace test/gtest/CMakeLists.txt \
+      --replace "include(googletest)" ""
+
+    ln -sf ${gfx900} src/kernels/gfx900.kdb
+    ln -sf ${gfx906} src/kernels/gfx906.kdb
+    ln -sf ${gfx908} src/kernels/gfx908.kdb
+    ln -sf ${gfx90a} src/kernels/gfx90a.kdb
+    ln -sf ${gfx1030} src/kernels/gfx1030.kdb
+  '';
+
+  # Unfortunately, it seems like we have to call make on these manually
+  postBuild = lib.optionalString buildDocs ''
+    python -m sphinx -T -E -b html -d _build/doctrees -D language=en ../docs _build/html
+  '' + lib.optionalString buildTests ''
+    make -j$NIX_BUILD_CORES check
+  '';
+
+  postInstall = ''
+    rm $out/bin/install_precompiled_kernels.sh
+    ln -sf ${gfx900} $out/share/miopen/db/gfx900.kdb
+    ln -sf ${gfx906} $out/share/miopen/db/gfx906.kdb
+    ln -sf ${gfx908} $out/share/miopen/db/gfx908.kdb
+    ln -sf ${gfx90a} $out/share/miopen/db/gfx90a.kdb
+    ln -sf ${gfx1030} $out/share/miopen/db/gfx1030.kdb
+  '' + lib.optionalString buildDocs ''
+    mv ../doc/html $out/share/doc/miopen-${if useOpenCL then "opencl" else "hip"}
+  '' + lib.optionalString buildTests ''
+    mkdir -p $test/bin
+    mv bin/test_* $test/bin
+    patchelf --set-rpath $out/lib:${lib.makeLibraryPath (finalAttrs.buildInputs ++
+      [ clr rocm-comgr ])} $test/bin/*
+  '';
+
+  requiredSystemFeatures = [ "big-parallel" ];
+
+  passthru.updateScript = rocmUpdateScript {
+    name = finalAttrs.pname;
+    owner = finalAttrs.src.owner;
+    repo = finalAttrs.src.repo;
+  };
+
+  meta = with lib; {
+    description = "Machine intelligence library for ROCm";
+    homepage = "https://github.com/ROCmSoftwarePlatform/MIOpen";
+    license = with licenses; [ mit ];
+    maintainers = teams.rocm.members;
+    platforms = platforms.linux;
+    broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
+  };
+})
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/miopengemm/default.nix b/nixpkgs/pkgs/development/rocm-modules/5/miopengemm/default.nix
new file mode 100644
index 000000000000..bda94cee61b3
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/miopengemm/default.nix
@@ -0,0 +1,126 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, rocmUpdateScript
+, cmake
+, rocm-cmake
+, clr
+, clblast
+, texlive
+, doxygen
+, sphinx
+, openblas
+, python3Packages
+, buildDocs ? true
+, buildTests ? false
+, buildBenchmarks ? false
+}:
+
+let
+  latex = lib.optionalAttrs buildDocs texlive.combine {
+    inherit (texlive) scheme-small
+    latexmk
+    tex-gyre
+    fncychap
+    wrapfig
+    capt-of
+    framed
+    needspace
+    tabulary
+    varwidth
+    titlesec;
+  };
+in stdenv.mkDerivation (finalAttrs: {
+  pname = "miopengemm";
+  version = "5.5.0";
+
+  outputs = [
+    "out"
+  ] ++ lib.optionals buildDocs [
+    "doc"
+  ] ++ lib.optionals buildTests [
+    "test"
+  ] ++ lib.optionals buildBenchmarks [
+    "benchmark"
+  ];
+
+  src = fetchFromGitHub {
+    owner = "ROCmSoftwarePlatform";
+    repo = "MIOpenGEMM";
+    rev = "rocm-${finalAttrs.version}";
+    hash = "sha256-AiRzOMYRA/0nbQomyq4oOEwNZdkPYWRA2W6QFlctvFc=";
+  };
+
+  nativeBuildInputs = [
+    cmake
+    rocm-cmake
+    clr
+  ];
+
+  buildInputs = lib.optionals buildDocs [
+    latex
+    doxygen
+    sphinx
+    python3Packages.sphinx-rtd-theme
+    python3Packages.breathe
+  ] ++ lib.optionals buildTests [
+    openblas
+  ] ++ lib.optionals buildBenchmarks [
+    clblast
+    python3Packages.openai-triton
+  ];
+
+  cmakeFlags = [
+    # Manually define CMAKE_INSTALL_<DIR>
+    # See: https://github.com/NixOS/nixpkgs/pull/197838
+    "-DCMAKE_INSTALL_BINDIR=bin"
+    "-DCMAKE_INSTALL_LIBDIR=lib"
+    "-DCMAKE_INSTALL_INCLUDEDIR=include"
+  ] ++ lib.optionals buildTests [
+    "-DOPENBLAS=ON"
+  ] ++ lib.optionals buildBenchmarks [
+    "-DAPI_BENCH_MIOGEMM=ON"
+    "-DAPI_BENCH_CLBLAST=ON"
+    "-DAPI_BENCH_ISAAC=ON"
+  ];
+
+  # Unfortunately, it seems like we have to call make on these manually
+  postBuild = lib.optionalString buildDocs ''
+    export HOME=$(mktemp -d)
+    make doc
+  '' + lib.optionalString buildTests ''
+    make check
+  '' + lib.optionalString buildBenchmarks ''
+    make examples
+  '';
+
+  postInstall = lib.optionalString buildDocs ''
+    mv ../doc/html $out/share/doc/miopengemm
+    mv ../doc/pdf/miopengemm.pdf $out/share/doc/miopengemm
+  '' + lib.optionalString buildTests ''
+    mkdir -p $test/bin
+    find tests -executable -type f -exec mv {} $test/bin \;
+    patchelf --set-rpath ${lib.makeLibraryPath finalAttrs.buildInputs}:$out/lib $test/bin/*
+  '' + lib.optionalString buildBenchmarks ''
+    mkdir -p $benchmark/bin
+    find examples -executable -type f -exec mv {} $benchmark/bin \;
+    patchelf --set-rpath ${lib.makeLibraryPath finalAttrs.buildInputs}:$out/lib $benchmark/bin/*
+  '';
+
+  passthru.updateScript = rocmUpdateScript {
+    name = finalAttrs.pname;
+    owner = finalAttrs.src.owner;
+    repo = finalAttrs.src.repo;
+  };
+
+  meta = with lib; {
+    description = "OpenCL general matrix multiplication API for ROCm";
+    homepage = "https://github.com/ROCmSoftwarePlatform/MIOpenGEMM";
+    license = with licenses; [ mit ];
+    maintainers = teams.rocm.members;
+    platforms = platforms.linux;
+    # They are not making tags or releases, this may break other derivations in the future
+    # Use version major instead of minor, 6.0 will HOPEFULLY have a release or tag
+    broken = versions.major finalAttrs.version != versions.major stdenv.cc.version;
+  };
+})
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/mivisionx/default.nix b/nixpkgs/pkgs/development/rocm-modules/5/mivisionx/default.nix
new file mode 100644
index 000000000000..d6e198eb4c77
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/mivisionx/default.nix
@@ -0,0 +1,145 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, rocmUpdateScript
+, cmake
+, rocm-cmake
+, rocm-device-libs
+, clr
+, pkg-config
+, rpp
+, rocblas
+, miopengemm
+, miopen
+, migraphx
+, clang
+, openmp
+, protobuf
+, qtcreator
+, opencv
+, ffmpeg
+, boost
+, libjpeg_turbo
+, half
+, lmdb
+, rapidjson
+, rocm-docs-core
+, python3Packages
+, useOpenCL ? false
+, useCPU ? false
+, buildDocs ? false # Needs internet
+, gpuTargets ? [ ]
+}:
+
+stdenv.mkDerivation (finalAttrs: {
+  pname = "mivisionx-" + (
+    if (!useOpenCL && !useCPU) then "hip"
+    else if (!useOpenCL && !useCPU) then "opencl"
+    else "cpu"
+  );
+
+  version = "5.7.0";
+
+  src = fetchFromGitHub {
+    owner = "GPUOpen-ProfessionalCompute-Libraries";
+    repo = "MIVisionX";
+    rev = "rocm-${finalAttrs.version}";
+    hash = "sha256-Z7UIqJWuSD+/FoZ1VIbITp4R/bwaqFCQqsL8CRW73Ek=";
+  };
+
+  nativeBuildInputs = [
+    cmake
+    rocm-cmake
+    clr
+    pkg-config
+  ] ++ lib.optionals buildDocs [
+    rocm-docs-core
+    python3Packages.python
+  ];
+
+  buildInputs = [
+    miopengemm
+    miopen
+    migraphx
+    rpp
+    rocblas
+    openmp
+    half
+    protobuf
+    qtcreator
+    opencv
+    ffmpeg
+    boost
+    libjpeg_turbo
+    lmdb
+    rapidjson
+    python3Packages.pybind11
+    python3Packages.numpy
+    python3Packages.torchWithRocm
+  ];
+
+  cmakeFlags = [
+    "-DROCM_PATH=${clr}"
+    "-DAMDRPP_PATH=${rpp}"
+    # Manually define CMAKE_INSTALL_<DIR>
+    # See: https://github.com/NixOS/nixpkgs/pull/197838
+    "-DCMAKE_INSTALL_BINDIR=bin"
+    "-DCMAKE_INSTALL_LIBDIR=lib"
+    "-DCMAKE_INSTALL_INCLUDEDIR=include"
+    "-DCMAKE_INSTALL_PREFIX_PYTHON=lib"
+    # "-DAMD_FP16_SUPPORT=ON" `error: typedef redefinition with different types ('__half' vs 'half_float::half')`
+  ] ++ lib.optionals (gpuTargets != [ ]) [
+    "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}"
+  ] ++ lib.optionals (!useOpenCL && !useCPU) [
+    "-DBACKEND=HIP"
+  ] ++ lib.optionals (useOpenCL && !useCPU) [
+    "-DBACKEND=OCL"
+  ] ++ lib.optionals useCPU [
+    "-DBACKEND=CPU"
+  ];
+
+  postPatch = ''
+    # We need to not use hipcc and define the CXXFLAGS manually due to `undefined hidden symbol: tensorflow:: ...`
+    export CXXFLAGS+="--rocm-path=${clr} --rocm-device-lib-path=${rocm-device-libs}/amdgcn/bitcode"
+    patchShebangs rocAL/rocAL_pybind/examples
+
+    # Properly find miopengemm and miopen
+    substituteInPlace amd_openvx_extensions/CMakeLists.txt \
+      --replace "miopengemm PATHS \''${ROCM_PATH} QUIET" "miopengemm PATHS ${miopengemm} QUIET" \
+      --replace "miopen     PATHS \''${ROCM_PATH} QUIET" "miopen PATHS ${miopen} QUIET" \
+      --replace "\''${ROCM_PATH}/include/miopen/config.h" "${miopen}/include/miopen/config.h"
+
+    # Properly find turbojpeg
+    substituteInPlace amd_openvx/cmake/FindTurboJpeg.cmake \
+      --replace "\''${TURBO_JPEG_PATH}/include" "${libjpeg_turbo.dev}/include" \
+      --replace "\''${TURBO_JPEG_PATH}/lib" "${libjpeg_turbo.out}/lib"
+
+    # Fix bad paths
+    substituteInPlace rocAL/rocAL/rocAL_hip/CMakeLists.txt amd_openvx_extensions/amd_nn/nn_hip/CMakeLists.txt amd_openvx/openvx/hipvx/CMakeLists.txt \
+      --replace "COMPILER_FOR_HIP \''${ROCM_PATH}/llvm/bin/clang++" "COMPILER_FOR_HIP ${clang}/bin/clang++"
+  '';
+
+  postBuild = lib.optionalString buildDocs ''
+    python3 -m sphinx -T -E -b html -d _build/doctrees -D language=en ../docs _build/html
+  '';
+
+  postInstall = lib.optionalString (!useOpenCL && !useCPU) ''
+    patchelf $out/lib/rocal_pybind*.so --shrink-rpath --allowed-rpath-prefixes "$NIX_STORE"
+    chmod +x $out/lib/rocal_pybind*.so
+  '';
+
+  passthru.updateScript = rocmUpdateScript {
+    name = finalAttrs.pname;
+    owner = finalAttrs.src.owner;
+    repo = finalAttrs.src.repo;
+  };
+
+  meta = with lib; {
+    description = "Set of comprehensive computer vision and machine intelligence libraries, utilities, and applications";
+    homepage = "https://github.com/GPUOpen-ProfessionalCompute-Libraries/MIVisionX";
+    license = with licenses; [ mit ];
+    maintainers = teams.rocm.members;
+    platforms = platforms.linux;
+    broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
+  };
+})
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/rccl/default.nix b/nixpkgs/pkgs/development/rocm-modules/5/rccl/default.nix
new file mode 100644
index 000000000000..d4045252bae4
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/rccl/default.nix
@@ -0,0 +1,91 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, rocmUpdateScript
+, cmake
+, rocm-cmake
+, rocm-smi
+, clr
+, perl
+, hipify
+, gtest
+, chrpath
+, buildTests ? false
+, gpuTargets ? [ ]
+}:
+
+stdenv.mkDerivation (finalAttrs: {
+  pname = "rccl";
+  version = "5.7.0";
+
+  outputs = [
+    "out"
+  ] ++ lib.optionals buildTests [
+    "test"
+  ];
+
+  src = fetchFromGitHub {
+    owner = "ROCmSoftwarePlatform";
+    repo = "rccl";
+    rev = "rocm-${finalAttrs.version}";
+    hash = "sha256-Abrwmsjnkx9JVTrARP/BM965g+R10lY+XPwthy/SG0k=";
+  };
+
+  nativeBuildInputs = [
+    cmake
+    rocm-cmake
+    clr
+    perl
+    hipify
+  ];
+
+  buildInputs = [
+    rocm-smi
+    gtest
+  ] ++ lib.optionals buildTests [
+    chrpath
+  ];
+
+  cmakeFlags = [
+    "-DCMAKE_CXX_COMPILER=hipcc"
+    "-DBUILD_BFD=OFF" # Can't get it to detect bfd.h
+    # Manually define CMAKE_INSTALL_<DIR>
+    # See: https://github.com/NixOS/nixpkgs/pull/197838
+    "-DCMAKE_INSTALL_BINDIR=bin"
+    "-DCMAKE_INSTALL_LIBDIR=lib"
+    "-DCMAKE_INSTALL_INCLUDEDIR=include"
+  ] ++ lib.optionals (gpuTargets != [ ]) [
+    "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}"
+  ] ++ lib.optionals buildTests [
+    "-DBUILD_TESTS=ON"
+  ];
+
+  postPatch = ''
+    patchShebangs src tools
+
+    # Really strange behavior, `#!/usr/bin/env perl` should work...
+    substituteInPlace CMakeLists.txt \
+      --replace "\''$ \''${hipify-perl_executable}" "${perl}/bin/perl ${hipify}/bin/hipify-perl"
+  '';
+
+  postInstall = lib.optionalString buildTests ''
+    mkdir -p $test/bin
+    mv $out/bin/* $test/bin
+    rmdir $out/bin
+  '';
+
+  passthru.updateScript = rocmUpdateScript {
+    name = finalAttrs.pname;
+    owner = finalAttrs.src.owner;
+    repo = finalAttrs.src.repo;
+  };
+
+  meta = with lib; {
+    description = "ROCm communication collectives library";
+    homepage = "https://github.com/ROCmSoftwarePlatform/rccl";
+    license = with licenses; [ bsd2 bsd3 ];
+    maintainers = teams.rocm.members;
+    platforms = platforms.linux;
+    broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
+  };
+})
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/rdc/default.nix b/nixpkgs/pkgs/development/rocm-modules/5/rdc/default.nix
new file mode 100644
index 000000000000..134b946c5f7a
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/rdc/default.nix
@@ -0,0 +1,126 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, rocmUpdateScript
+, cmake
+, rocm-smi
+, rocm-runtime
+, libcap
+, grpc
+, protobuf
+, openssl
+, doxygen
+, graphviz
+, texlive
+, gtest
+, buildDocs ? true
+, buildTests ? false
+}:
+
+let
+  latex = lib.optionalAttrs buildDocs texlive.combine {
+    inherit (texlive) scheme-small
+    changepage
+    latexmk
+    varwidth
+    multirow
+    hanging
+    adjustbox
+    collectbox
+    stackengine
+    enumitem
+    alphalph
+    wasysym
+    sectsty
+    tocloft
+    newunicodechar
+    etoc
+    helvetic
+    wasy
+    courier;
+  };
+in stdenv.mkDerivation (finalAttrs: {
+  pname = "rdc";
+  version = "5.7.0";
+
+  outputs = [
+    "out"
+  ] ++ lib.optionals buildDocs [
+    "doc"
+  ] ++ lib.optionals buildTests [
+    "test"
+  ];
+
+  src = fetchFromGitHub {
+    owner = "RadeonOpenCompute";
+    repo = "rdc";
+    rev = "rocm-${finalAttrs.version}";
+    hash = "sha256-xZD/WI/LfNtKK9j6ZjuU0OTTFZz3G4atyD5mVcSsQ8A=";
+  };
+
+  nativeBuildInputs = [
+    cmake
+    protobuf
+  ] ++ lib.optionals buildDocs [
+    doxygen
+    graphviz
+    latex
+  ];
+
+  buildInputs = [
+    rocm-smi
+    rocm-runtime
+    libcap
+    grpc
+    openssl
+  ] ++ lib.optionals buildTests [
+    gtest
+  ];
+
+  cmakeFlags = [
+    "-DCMAKE_VERBOSE_MAKEFILE=OFF"
+    "-DRDC_INSTALL_PREFIX=${placeholder "out"}"
+    "-DBUILD_ROCRTEST=ON"
+    "-DRSMI_INC_DIR=${rocm-smi}/include"
+    "-DRSMI_LIB_DIR=${rocm-smi}/lib"
+    "-DGRPC_ROOT=${grpc}"
+    # Manually define CMAKE_INSTALL_<DIR>
+    # See: https://github.com/NixOS/nixpkgs/pull/197838
+    "-DCMAKE_INSTALL_BINDIR=bin"
+    "-DCMAKE_INSTALL_LIBDIR=lib"
+    "-DCMAKE_INSTALL_INCLUDEDIR=include"
+    "-DCMAKE_INSTALL_LIBEXECDIR=libexec"
+    "-DCMAKE_INSTALL_DOCDIR=doc"
+  ] ++ lib.optionals buildTests [
+    "-DBUILD_TESTS=ON"
+  ];
+
+  postPatch = ''
+    substituteInPlace CMakeLists.txt \
+      --replace "file(STRINGS /etc/os-release LINUX_DISTRO LIMIT_COUNT 1 REGEX \"NAME=\")" "set(LINUX_DISTRO \"NixOS\")"
+  '';
+
+  postInstall = ''
+    find $out/bin -executable -type f -exec \
+      patchelf {} --shrink-rpath --allowed-rpath-prefixes "$NIX_STORE" \;
+  '' + lib.optionalString buildTests ''
+    mkdir -p $test
+    mv $out/bin/rdctst_tests $test/bin
+  '';
+
+  passthru.updateScript = rocmUpdateScript {
+    name = finalAttrs.pname;
+    owner = finalAttrs.src.owner;
+    repo = finalAttrs.src.repo;
+  };
+
+  meta = with lib; {
+    description = "Simplifies administration and addresses infrastructure challenges in cluster and datacenter environments";
+    homepage = "https://github.com/RadeonOpenCompute/rdc";
+    license = with licenses; [ mit ];
+    maintainers = teams.rocm.members;
+    platforms = platforms.linux;
+    # broken = versions.minor finalAttrs.version != versions.minor rocm-smi.version;
+    broken = true; # Too many errors, unsure how to fix
+  };
+})
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/rocalution/default.nix b/nixpkgs/pkgs/development/rocm-modules/5/rocalution/default.nix
new file mode 100644
index 000000000000..80fd655557df
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/rocalution/default.nix
@@ -0,0 +1,115 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, rocmUpdateScript
+, cmake
+, rocm-cmake
+, rocblas
+, rocsparse
+, rocprim
+, rocrand
+, clr
+, git
+, openmp
+, openmpi
+, gtest
+, buildTests ? false
+, buildBenchmarks ? false
+, buildSamples ? false
+, gpuTargets ? [ ] # gpuTargets = [ "gfx803" "gfx900:xnack-" "gfx906:xnack-" ... ]
+}:
+
+stdenv.mkDerivation (finalAttrs: {
+  pname = "rocalution";
+  version = "5.7.0";
+
+  outputs = [
+    "out"
+  ] ++ lib.optionals buildTests [
+    "test"
+  ] ++ lib.optionals buildBenchmarks [
+    "benchmark"
+  ] ++ lib.optionals buildSamples [
+    "sample"
+  ];
+
+  src = fetchFromGitHub {
+    owner = "ROCmSoftwarePlatform";
+    repo = "rocALUTION";
+    rev = "rocm-${finalAttrs.version}";
+    hash = "sha256-+UGpFuZsC4+kmo8LWZWC2YoFJSdTukjN47e1YqW5Zu4=";
+  };
+
+  nativeBuildInputs = [
+    cmake
+    rocm-cmake
+    clr
+    git
+  ];
+
+  buildInputs = [
+    rocblas
+    rocsparse
+    rocprim
+    rocrand
+    openmp
+    openmpi
+  ] ++ lib.optionals buildTests [
+    gtest
+  ];
+
+  cmakeFlags = [
+    "-DCMAKE_CXX_COMPILER=hipcc"
+    "-DROCM_PATH=${clr}"
+    "-DHIP_ROOT_DIR=${clr}"
+    "-DSUPPORT_HIP=ON"
+    "-DSUPPORT_OMP=ON"
+    "-DSUPPORT_MPI=ON"
+    "-DBUILD_CLIENTS_SAMPLES=${if buildSamples then "ON" else "OFF"}"
+    # Manually define CMAKE_INSTALL_<DIR>
+    # See: https://github.com/NixOS/nixpkgs/pull/197838
+    "-DCMAKE_INSTALL_BINDIR=bin"
+    "-DCMAKE_INSTALL_LIBDIR=lib"
+    "-DCMAKE_INSTALL_INCLUDEDIR=include"
+  ] ++ lib.optionals (gpuTargets != [ ]) [
+    "-DAMDGPU_TARGETS=${lib.strings.concatStringsSep ";" gpuTargets}"
+  ] ++ lib.optionals buildTests [
+    "-DBUILD_CLIENTS_TESTS=ON"
+  ] ++ lib.optionals buildBenchmarks [
+    "-DBUILD_CLIENTS_BENCHMARKS=ON"
+  ];
+
+  postInstall = lib.optionalString buildTests ''
+    mkdir -p $test/bin
+    mv $out/bin/rocalution-test $test/bin
+  '' + lib.optionalString buildBenchmarks ''
+    mkdir -p $benchmark/bin
+    mv $out/bin/rocalution-bench $benchmark/bin
+  '' + lib.optionalString buildSamples ''
+    mkdir -p $sample/bin
+    mv clients/staging/* $sample/bin
+    rm $sample/bin/rocalution-test || true
+    rm $sample/bin/rocalution-bench || true
+
+    patchelf --set-rpath \
+      $out/lib:${lib.makeLibraryPath (finalAttrs.buildInputs ++ [ clr ])} \
+      $sample/bin/*
+  '' + lib.optionalString (buildTests || buildBenchmarks) ''
+    rmdir $out/bin
+  '';
+
+  passthru.updateScript = rocmUpdateScript {
+    name = finalAttrs.pname;
+    owner = finalAttrs.src.owner;
+    repo = finalAttrs.src.repo;
+  };
+
+  meta = with lib; {
+    description = "Iterative sparse solvers for ROCm";
+    homepage = "https://github.com/ROCmSoftwarePlatform/rocALUTION";
+    license = with licenses; [ mit ];
+    maintainers = teams.rocm.members;
+    platforms = platforms.linux;
+    broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
+  };
+})
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/rocblas/default.nix b/nixpkgs/pkgs/development/rocm-modules/5/rocblas/default.nix
new file mode 100644
index 000000000000..17732fd51681
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/rocblas/default.nix
@@ -0,0 +1,209 @@
+{ rocblas
+, lib
+, stdenv
+, fetchFromGitHub
+, rocmUpdateScript
+, runCommand
+, cmake
+, rocm-cmake
+, clr
+, python3
+, tensile
+, msgpack
+, libxml2
+, gtest
+, gfortran
+, openmp
+, amd-blis
+, python3Packages
+, buildTensile ? true
+, buildTests ? false
+, buildBenchmarks ? false
+, tensileLogic ? "asm_full"
+, tensileCOVersion ? "default"
+, tensileSepArch ? true
+, tensileLazyLib ? true
+, tensileLibFormat ? "msgpack"
+, gpuTargets ? [ "all" ]
+}:
+
+let
+  # NOTE: Update the default GPU targets on every update
+  gfx80 = (rocblas.override {
+    gpuTargets = [
+      "gfx803"
+    ];
+  }).overrideAttrs { pname = "rocblas-tensile-gfx80"; };
+
+  gfx90 = (rocblas.override {
+    gpuTargets = [
+      "gfx900"
+      "gfx906:xnack-"
+      "gfx908:xnack-"
+      "gfx90a:xnack+"
+      "gfx90a:xnack-"
+    ];
+  }).overrideAttrs { pname = "rocblas-tensile-gfx90"; };
+
+  gfx94 = (rocblas.override {
+    gpuTargets = [
+      "gfx940"
+      "gfx941"
+      "gfx942"
+    ];
+  }).overrideAttrs { pname = "rocblas-tensile-gfx94"; };
+
+  gfx10 = (rocblas.override {
+    gpuTargets = [
+      "gfx1010"
+      "gfx1012"
+      "gfx1030"
+    ];
+  }).overrideAttrs { pname = "rocblas-tensile-gfx10"; };
+
+  gfx11 = (rocblas.override {
+    gpuTargets = [
+      "gfx1100"
+      "gfx1101"
+      "gfx1102"
+    ];
+  }).overrideAttrs { pname = "rocblas-tensile-gfx11"; };
+
+  # Unfortunately, we have to do two full builds, otherwise we get overlapping _fallback.dat files
+  fallbacks = rocblas.overrideAttrs { pname = "rocblas-tensile-fallbacks"; };
+in stdenv.mkDerivation (finalAttrs: {
+  pname = "rocblas";
+  version = "5.7.0";
+
+  outputs = [
+    "out"
+  ] ++ lib.optionals buildTests [
+    "test"
+  ] ++ lib.optionals buildBenchmarks [
+    "benchmark"
+  ];
+
+  src = fetchFromGitHub {
+    owner = "ROCmSoftwarePlatform";
+    repo = "rocBLAS";
+    rev = "rocm-${finalAttrs.version}";
+    hash = "sha256-3wKnwvAra8u9xqlC05wUD+gSoBILTVJFU2cIV6xv3Lk=";
+  };
+
+  nativeBuildInputs = [
+    cmake
+    rocm-cmake
+    clr
+  ];
+
+  buildInputs = [
+    python3
+  ] ++ lib.optionals buildTensile [
+    msgpack
+    libxml2
+    python3Packages.msgpack
+    python3Packages.joblib
+  ] ++ lib.optionals buildTests [
+    gtest
+  ] ++ lib.optionals (buildTests || buildBenchmarks) [
+    gfortran
+    openmp
+    amd-blis
+  ] ++ lib.optionals (buildTensile || buildTests || buildBenchmarks) [
+    python3Packages.pyyaml
+  ];
+
+  cmakeFlags = [
+    "-DCMAKE_C_COMPILER=hipcc"
+    "-DCMAKE_CXX_COMPILER=hipcc"
+    "-Dpython=python3"
+    "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}"
+    "-DBUILD_WITH_TENSILE=${if buildTensile then "ON" else "OFF"}"
+    # Manually define CMAKE_INSTALL_<DIR>
+    # See: https://github.com/NixOS/nixpkgs/pull/197838
+    "-DCMAKE_INSTALL_BINDIR=bin"
+    "-DCMAKE_INSTALL_LIBDIR=lib"
+    "-DCMAKE_INSTALL_INCLUDEDIR=include"
+  ] ++ lib.optionals buildTensile [
+    "-DVIRTUALENV_HOME_DIR=/build/source/tensile"
+    "-DTensile_TEST_LOCAL_PATH=/build/source/tensile"
+    "-DTensile_ROOT=/build/source/tensile/${python3.sitePackages}/Tensile"
+    "-DTensile_LOGIC=${tensileLogic}"
+    "-DTensile_CODE_OBJECT_VERSION=${tensileCOVersion}"
+    "-DTensile_SEPARATE_ARCHITECTURES=${if tensileSepArch then "ON" else "OFF"}"
+    "-DTensile_LAZY_LIBRARY_LOADING=${if tensileLazyLib then "ON" else "OFF"}"
+    "-DTensile_LIBRARY_FORMAT=${tensileLibFormat}"
+  ] ++ lib.optionals buildTests [
+    "-DBUILD_CLIENTS_TESTS=ON"
+  ] ++ lib.optionals buildBenchmarks [
+    "-DBUILD_CLIENTS_BENCHMARKS=ON"
+  ] ++ lib.optionals (buildTests || buildBenchmarks) [
+    "-DCMAKE_CXX_FLAGS=-I${amd-blis}/include/blis"
+  ];
+
+  postPatch = lib.optionalString (finalAttrs.pname != "rocblas") ''
+    # Return early and install tensile files manually
+    substituteInPlace library/src/CMakeLists.txt \
+      --replace "set_target_properties( TensileHost PROPERTIES OUTPUT_NAME" "return()''\nset_target_properties( TensileHost PROPERTIES OUTPUT_NAME"
+  '' + lib.optionalString (buildTensile && finalAttrs.pname == "rocblas") ''
+    # Link the prebuilt Tensile files
+    mkdir -p build/Tensile/library
+
+    for path in ${gfx80} ${gfx90} ${gfx94} ${gfx10} ${gfx11} ${fallbacks}; do
+      ln -s $path/lib/rocblas/library/* build/Tensile/library
+    done
+
+    unlink build/Tensile/library/TensileManifest.txt
+  '' + lib.optionalString buildTensile ''
+    # Tensile REALLY wants to write to the nix directory if we include it normally
+    cp -a ${tensile} tensile
+    chmod +w -R tensile
+
+    # Rewrap Tensile
+    substituteInPlace tensile/bin/{.t*,.T*,*} \
+      --replace "${tensile}" "/build/source/tensile"
+
+    substituteInPlace CMakeLists.txt \
+      --replace "include(virtualenv)" "" \
+      --replace "virtualenv_install(\''${Tensile_TEST_LOCAL_PATH})" ""
+  '';
+
+  postInstall = lib.optionalString (finalAttrs.pname == "rocblas") ''
+    ln -sf ${fallbacks}/lib/rocblas/library/TensileManifest.txt $out/lib/rocblas/library
+  '' + lib.optionalString (finalAttrs.pname != "rocblas") ''
+    mkdir -p $out/lib/rocblas/library
+    rm -rf $out/share
+  '' + lib.optionalString (finalAttrs.pname != "rocblas" && finalAttrs.pname != "rocblas-tensile-fallbacks") ''
+    rm Tensile/library/{TensileManifest.txt,*_fallback.dat}
+    mv Tensile/library/* $out/lib/rocblas/library
+  '' + lib.optionalString (finalAttrs.pname == "rocblas-tensile-fallbacks") ''
+    mv Tensile/library/{TensileManifest.txt,*_fallback.dat} $out/lib/rocblas/library
+  '' + lib.optionalString buildTests ''
+    mkdir -p $test/bin
+    cp -a $out/bin/* $test/bin
+    rm $test/bin/*-bench || true
+  '' + lib.optionalString buildBenchmarks ''
+    mkdir -p $benchmark/bin
+    cp -a $out/bin/* $benchmark/bin
+    rm $benchmark/bin/*-test || true
+  '' + lib.optionalString (buildTests || buildBenchmarks ) ''
+    rm -rf $out/bin
+  '';
+
+  passthru.updateScript = rocmUpdateScript {
+    name = finalAttrs.pname;
+    owner = finalAttrs.src.owner;
+    repo = finalAttrs.src.repo;
+  };
+
+  requiredSystemFeatures = [ "big-parallel" ];
+
+  meta = with lib; {
+    description = "BLAS implementation for ROCm platform";
+    homepage = "https://github.com/ROCmSoftwarePlatform/rocBLAS";
+    license = with licenses; [ mit ];
+    maintainers = teams.rocm.members;
+    platforms = platforms.linux;
+    broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
+  };
+})
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/rocdbgapi/default.nix b/nixpkgs/pkgs/development/rocm-modules/5/rocdbgapi/default.nix
new file mode 100644
index 000000000000..41c1178f1089
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/rocdbgapi/default.nix
@@ -0,0 +1,112 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, rocmUpdateScript
+, cmake
+, rocm-cmake
+, git
+, rocm-comgr
+, rocm-runtime
+, hwdata
+, texlive
+, doxygen
+, graphviz
+, buildDocs ? true
+}:
+
+let
+  latex = lib.optionalAttrs buildDocs texlive.combine {
+    inherit (texlive) scheme-small
+    changepage
+    latexmk
+    varwidth
+    multirow
+    hanging
+    adjustbox
+    collectbox
+    stackengine
+    enumitem
+    alphalph
+    wasysym
+    sectsty
+    tocloft
+    newunicodechar
+    etoc
+    helvetic
+    wasy
+    courier;
+  };
+in stdenv.mkDerivation (finalAttrs: {
+  pname = "rocdbgapi";
+  version = "5.7.0";
+
+  outputs = [
+    "out"
+  ] ++ lib.optionals buildDocs [
+    "doc"
+  ];
+
+  src = fetchFromGitHub {
+    owner = "ROCm-Developer-Tools";
+    repo = "ROCdbgapi";
+    rev = "rocm-${finalAttrs.version}";
+    hash = "sha256-qMXvgcS61lgcylz62ErYq8fhpYIR31skQEeKUryuP1w=";
+  };
+
+  nativeBuildInputs = [
+    cmake
+    rocm-cmake
+    git
+  ] ++ lib.optionals buildDocs [
+    latex
+    doxygen
+    graphviz
+  ];
+
+  buildInputs = [
+    rocm-comgr
+    rocm-runtime
+    hwdata
+  ];
+
+  cmakeFlags = [
+    "-DPCI_IDS_PATH=${hwdata}/share/hwdata"
+    # Manually define CMAKE_INSTALL_<DIR>
+    # See: https://github.com/NixOS/nixpkgs/pull/197838
+    "-DCMAKE_INSTALL_BINDIR=bin"
+    "-DCMAKE_INSTALL_LIBDIR=lib"
+    "-DCMAKE_INSTALL_INCLUDEDIR=include"
+  ];
+
+  # Unfortunately, it seems like we have to call make on this manually
+  postBuild = lib.optionalString buildDocs ''
+    export HOME=$(mktemp -d)
+    make -j$NIX_BUILD_CORES doc
+  '';
+
+  postInstall = ''
+    substituteInPlace $out/lib/cmake/amd-dbgapi/amd-dbgapi-config.cmake \
+      --replace "/build/source/build/" ""
+
+    substituteInPlace $out/lib/cmake/amd-dbgapi/amd-dbgapi-targets.cmake \
+      --replace "/build/source/build" "$out"
+  '' + lib.optionalString buildDocs ''
+    mv $out/share/html/amd-dbgapi $doc/share/doc/amd-dbgapi/html
+    rmdir $out/share/html
+  '';
+
+  passthru.updateScript = rocmUpdateScript {
+    name = finalAttrs.pname;
+    owner = finalAttrs.src.owner;
+    repo = finalAttrs.src.repo;
+  };
+
+  meta = with lib; {
+    description = "Debugger support for control of execution and inspection state";
+    homepage = "https://github.com/ROCm-Developer-Tools/ROCdbgapi";
+    license = with licenses; [ mit ];
+    maintainers = teams.rocm.members;
+    platforms = platforms.linux;
+    broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
+  };
+})
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/rocfft/default.nix b/nixpkgs/pkgs/development/rocm-modules/5/rocfft/default.nix
new file mode 100644
index 000000000000..ac50318622ce
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/rocfft/default.nix
@@ -0,0 +1,169 @@
+{ rocfft
+, lib
+, stdenv
+, fetchFromGitHub
+, rocmUpdateScript
+, cmake
+, clr
+, python3
+, rocm-cmake
+, sqlite
+, boost
+, fftw
+, fftwFloat
+, gtest
+, openmp
+, rocrand
+, gpuTargets ? [ ]
+}:
+
+stdenv.mkDerivation (finalAttrs: {
+  pname = "rocfft";
+  version = "5.7.0";
+
+  src = fetchFromGitHub {
+    owner = "ROCmSoftwarePlatform";
+    repo = "rocFFT";
+    rev = "rocm-${finalAttrs.version}";
+    hash = "sha256-GZSi03geTT+NUztBWhGYyghLqJGsFjUQzVAKQ7d03uA=";
+  };
+
+  nativeBuildInputs = [
+    cmake
+    clr
+    python3
+    rocm-cmake
+  ];
+
+  buildInputs = [ sqlite ];
+
+  cmakeFlags = [
+    "-DCMAKE_C_COMPILER=hipcc"
+    "-DCMAKE_CXX_COMPILER=hipcc"
+    "-DSQLITE_USE_SYSTEM_PACKAGE=ON"
+    # Manually define CMAKE_INSTALL_<DIR>
+    # See: https://github.com/NixOS/nixpkgs/pull/197838
+    "-DCMAKE_INSTALL_BINDIR=bin"
+    "-DCMAKE_INSTALL_LIBDIR=lib"
+    "-DCMAKE_INSTALL_INCLUDEDIR=include"
+  ] ++ lib.optionals (gpuTargets != [ ]) [
+    "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}"
+  ];
+
+  passthru = {
+    test = stdenv.mkDerivation {
+      pname = "${finalAttrs.pname}-test";
+      inherit (finalAttrs) version src;
+
+      sourceRoot = "${finalAttrs.src.name}/clients/tests";
+
+      nativeBuildInputs = [
+        cmake
+        clr
+        rocm-cmake
+      ];
+
+      buildInputs = [
+        boost
+        fftw
+        fftwFloat
+        finalAttrs.finalPackage
+        gtest
+        openmp
+        rocrand
+      ];
+
+      cmakeFlags = [
+        "-DCMAKE_C_COMPILER=hipcc"
+        "-DCMAKE_CXX_COMPILER=hipcc"
+      ];
+
+      postInstall = ''
+        rm -r "$out/lib/fftw"
+        rmdir "$out/lib"
+      '';
+    };
+
+    benchmark = stdenv.mkDerivation {
+      pname = "${finalAttrs.pname}-benchmark";
+      inherit (finalAttrs) version src;
+
+      sourceRoot = "${finalAttrs.src.name}/clients/rider";
+
+      nativeBuildInputs = [
+        cmake
+        clr
+        rocm-cmake
+      ];
+
+      buildInputs = [
+        boost
+        finalAttrs.finalPackage
+        openmp
+        (python3.withPackages (ps: with ps; [
+          pandas
+          scipy
+        ]))
+        rocrand
+      ];
+
+      cmakeFlags = [
+        "-DCMAKE_C_COMPILER=hipcc"
+        "-DCMAKE_CXX_COMPILER=hipcc"
+      ];
+
+      postInstall = ''
+        cp -a ../../../scripts/perf "$out/bin"
+      '';
+    };
+
+    samples = stdenv.mkDerivation {
+      pname = "${finalAttrs.pname}-samples";
+      inherit (finalAttrs) version src;
+
+      sourceRoot = "${finalAttrs.src.name}/clients/samples";
+
+      nativeBuildInputs = [
+        cmake
+        clr
+        rocm-cmake
+      ];
+
+      buildInputs = [
+        boost
+        finalAttrs.finalPackage
+        openmp
+        rocrand
+      ];
+
+      cmakeFlags = [
+        "-DCMAKE_C_COMPILER=hipcc"
+        "-DCMAKE_CXX_COMPILER=hipcc"
+      ];
+
+      installPhase = ''
+        runHook preInstall
+        mkdir "$out"
+        cp -a bin "$out"
+        runHook postInstall
+      '';
+    };
+
+    updateScript = rocmUpdateScript {
+      name = finalAttrs.pname;
+      owner = finalAttrs.src.owner;
+      repo = finalAttrs.src.repo;
+    };
+  };
+
+  requiredSystemFeatures = [ "big-parallel" ];
+
+  meta = with lib; {
+    description = "FFT implementation for ROCm";
+    homepage = "https://github.com/ROCmSoftwarePlatform/rocFFT";
+    license = with licenses; [ mit ];
+    maintainers = with maintainers; [ kira-bruneau ] ++ teams.rocm.members;
+    platforms = platforms.linux;
+    broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
+  };
+})
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/rocgdb/default.nix b/nixpkgs/pkgs/development/rocm-modules/5/rocgdb/default.nix
new file mode 100644
index 000000000000..a2f4435ee7bc
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/rocgdb/default.nix
@@ -0,0 +1,58 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, rocmUpdateScript
+, pkg-config
+, texinfo
+, bison
+, flex
+, zlib
+, elfutils
+, gmp
+, ncurses
+, expat
+}:
+
+stdenv.mkDerivation (finalAttrs: {
+  pname = "rocgdb";
+  version = "5.7.0";
+
+  src = fetchFromGitHub {
+    owner = "ROCm-Developer-Tools";
+    repo = "ROCgdb";
+    rev = "rocm-${finalAttrs.version}";
+    hash = "sha256-TlT7vvTrVd7P6ilVnWIG5VIrjTleFgDezK/mudBV+xE=";
+  };
+
+  nativeBuildInputs = [
+    pkg-config
+    texinfo # For makeinfo
+    bison
+    flex
+  ];
+
+  buildInputs = [
+    zlib
+    elfutils
+    gmp
+    ncurses
+    expat
+  ];
+
+  # `-Wno-format-nonliteral` doesn't work
+  env.NIX_CFLAGS_COMPILE = "-Wno-error=format-security";
+
+  passthru.updateScript = rocmUpdateScript {
+    name = finalAttrs.pname;
+    owner = finalAttrs.src.owner;
+    repo = finalAttrs.src.repo;
+  };
+
+  meta = with lib; {
+    description = "ROCm source-level debugger for Linux, based on GDB";
+    homepage = "https://github.com/ROCm-Developer-Tools/ROCgdb";
+    license = with licenses; [ gpl2 gpl3 bsd3 ];
+    maintainers = teams.rocm.members;
+    platforms = platforms.linux;
+  };
+})
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/rocm-cmake/default.nix b/nixpkgs/pkgs/development/rocm-modules/5/rocm-cmake/default.nix
new file mode 100644
index 000000000000..04ae947d3a4a
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/rocm-cmake/default.nix
@@ -0,0 +1,37 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, rocmUpdateScript
+, cmake
+}:
+
+stdenv.mkDerivation (finalAttrs: {
+  pname = "rocm-cmake";
+  version = "5.7.0";
+
+  src = fetchFromGitHub {
+    owner = "RadeonOpenCompute";
+    repo = "rocm-cmake";
+    rev = "rocm-${finalAttrs.version}";
+    hash = "sha256-aVjzuJ4BiSfwOdjufFc5CznfnL8di5h992zl+pzD0DU=";
+  };
+
+  nativeBuildInputs = [ cmake ];
+
+  passthru.updateScript = rocmUpdateScript {
+    name = finalAttrs.pname;
+    owner = finalAttrs.src.owner;
+    repo = finalAttrs.src.repo;
+    page = "releases?per_page=2";
+    filter = ".[1].tag_name | split(\"-\") | .[1]";
+  };
+
+  meta = with lib; {
+    description = "CMake modules for common build tasks for the ROCm stack";
+    homepage = "https://github.com/RadeonOpenCompute/rocm-cmake";
+    license = licenses.mit;
+    maintainers = teams.rocm.members;
+    platforms = platforms.unix;
+    broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
+  };
+})
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/rocm-comgr/default.nix b/nixpkgs/pkgs/development/rocm-modules/5/rocm-comgr/default.nix
new file mode 100644
index 000000000000..c3c4c5fab3cd
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/rocm-comgr/default.nix
@@ -0,0 +1,55 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, rocmUpdateScript
+, cmake
+, rocm-cmake
+, rocm-device-libs
+, libxml2
+}:
+
+let
+  llvmNativeTarget =
+    if stdenv.isx86_64 then "X86"
+    else if stdenv.isAarch64 then "AArch64"
+    else throw "Unsupported ROCm LLVM platform";
+in stdenv.mkDerivation (finalAttrs: {
+  pname = "rocm-comgr";
+  version = "5.7.0";
+
+  src = fetchFromGitHub {
+    owner = "RadeonOpenCompute";
+    repo = "ROCm-CompilerSupport";
+    rev = "rocm-${finalAttrs.version}";
+    hash = "sha256-QB3G0V92UTW67hD6+zSuExN1+eMT820iYSlMyZeWSFw=";
+  };
+
+  sourceRoot = "${finalAttrs.src.name}/lib/comgr";
+
+  nativeBuildInputs = [
+    cmake
+    rocm-cmake
+  ];
+
+  buildInputs = [
+    rocm-device-libs
+    libxml2
+  ];
+
+  cmakeFlags = [ "-DLLVM_TARGETS_TO_BUILD=AMDGPU;X86" ];
+
+  passthru.updateScript = rocmUpdateScript {
+    name = finalAttrs.pname;
+    owner = finalAttrs.src.owner;
+    repo = finalAttrs.src.repo;
+  };
+
+  meta = with lib; {
+    description = "APIs for compiling and inspecting AMDGPU code objects";
+    homepage = "https://github.com/RadeonOpenCompute/ROCm-CompilerSupport/tree/amd-stg-open/lib/comgr";
+    license = licenses.ncsa;
+    maintainers = with maintainers; [ lovesegfault ] ++ teams.rocm.members;
+    platforms = platforms.linux;
+    broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
+  };
+})
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/rocm-core/default.nix b/nixpkgs/pkgs/development/rocm-modules/5/rocm-core/default.nix
new file mode 100644
index 000000000000..aae431be8e62
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/rocm-core/default.nix
@@ -0,0 +1,36 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, rocmUpdateScript
+, cmake
+}:
+
+stdenv.mkDerivation (finalAttrs: {
+  pname = "rocm-core";
+  version = "5.7.0";
+
+  src = fetchFromGitHub {
+    owner = "RadeonOpenCompute";
+    repo = "rocm-core";
+    rev = "rocm-${finalAttrs.version}";
+    hash = "sha256-jFAHLqf/AR27Nbuq8aypWiKqApNcTgG5LWESVjVCKIg=";
+  };
+
+  nativeBuildInputs = [ cmake ];
+  cmakeFlags = [ "-DROCM_VERSION=${finalAttrs.version}" ];
+
+  passthru.updateScript = rocmUpdateScript {
+    name = finalAttrs.pname;
+    owner = finalAttrs.src.owner;
+    repo = finalAttrs.src.repo;
+  };
+
+  meta = with lib; {
+    description = "Utility for getting the ROCm release version";
+    homepage = "https://github.com/RadeonOpenCompute/rocm-core";
+    license = with licenses; [ mit ];
+    maintainers = teams.rocm.members;
+    platforms = platforms.linux;
+    broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
+  };
+})
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/rocm-device-libs/cmake.patch b/nixpkgs/pkgs/development/rocm-modules/5/rocm-device-libs/cmake.patch
new file mode 100644
index 000000000000..500ff37a9905
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/rocm-device-libs/cmake.patch
@@ -0,0 +1,43 @@
+diff --git a/cmake/Packages.cmake b/cmake/Packages.cmake
+index 07c60eb..c736b3e 100644
+--- a/cmake/Packages.cmake
++++ b/cmake/Packages.cmake
+@@ -12,24 +12,29 @@ set_target_properties(${target} PROPERTIES
+   IMPORTED_LOCATION \"${target_path}\")")
+ endforeach()
+ configure_file(AMDDeviceLibsConfig.cmake.in
+-  ${PACKAGE_PREFIX}/AMDDeviceLibsConfig.cmake
++  lib/cmake/AMDDeviceLibs/AMDDeviceLibsConfig.cmake
+   @ONLY)
+ 
+ 
+ set(install_path_suffix "amdgcn/bitcode")
+ 
+ # Generate the install-tree package.
+-# We do not know the absolute path to the intall tree until we are installed,
+-# so we calculate it dynamically in AMD_DEVICE_LIBS_PREFIX_CODE and use
+-# relative paths in the target imports in AMD_DEVICE_LIBS_TARGET_CODE.
+-set(AMD_DEVICE_LIBS_PREFIX_CODE "
++if(IS_ABSOLUTE "${CMAKE_INSTALL_PREFIX}")
++  set(AMD_DEVICE_LIBS_PREFIX_CODE "set(AMD_DEVICE_LIBS_PREFIX \"${CMAKE_INSTALL_PREFIX}\")")
++else()
++  # We do not know the absolute path to the install tree until we are installed,
++  # so we calculate it dynamically in AMD_DEVICE_LIBS_PREFIX_CODE and use
++  # relative paths in the target imports in AMD_DEVICE_LIBS_TARGET_CODE.
++  set(AMD_DEVICE_LIBS_PREFIX_CODE "
+ # Derive absolute install prefix from config file path.
+ get_filename_component(AMD_DEVICE_LIBS_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" PATH)")
+-string(REGEX REPLACE "/" ";" count "${PACKAGE_PREFIX}")
+-foreach(p ${count})
+-  set(AMD_DEVICE_LIBS_PREFIX_CODE "${AMD_DEVICE_LIBS_PREFIX_CODE}
++  string(REGEX REPLACE "/" ";" count "${PACKAGE_PREFIX}")
++  foreach(p ${count})
++    set(AMD_DEVICE_LIBS_PREFIX_CODE "${AMD_DEVICE_LIBS_PREFIX_CODE}
+ get_filename_component(AMD_DEVICE_LIBS_PREFIX \"\${AMD_DEVICE_LIBS_PREFIX}\" PATH)")
+-endforeach()
++  endforeach()
++endif()
++
+ set(AMD_DEVICE_LIBS_TARGET_CODE)
+ foreach(target ${AMDGCN_LIB_LIST})
+   get_target_property(target_name ${target} ARCHIVE_OUTPUT_NAME)
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/rocm-device-libs/default.nix b/nixpkgs/pkgs/development/rocm-modules/5/rocm-device-libs/default.nix
new file mode 100644
index 000000000000..594e21031284
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/rocm-device-libs/default.nix
@@ -0,0 +1,50 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, rocmUpdateScript
+, cmake
+, rocm-cmake
+, libxml2
+}:
+
+let
+  llvmNativeTarget =
+    if stdenv.isx86_64 then "X86"
+    else if stdenv.isAarch64 then "AArch64"
+    else throw "Unsupported ROCm LLVM platform";
+in stdenv.mkDerivation (finalAttrs: {
+  pname = "rocm-device-libs";
+  version = "5.7.0";
+
+  src = fetchFromGitHub {
+    owner = "RadeonOpenCompute";
+    repo = "ROCm-Device-Libs";
+    rev = "rocm-${finalAttrs.version}";
+    hash = "sha256-f6/LAhJ2mBDO1/JloHvl7MJyDo3WutbXd4IDknA9nzM=";
+  };
+
+  patches = [ ./cmake.patch ];
+
+  nativeBuildInputs = [
+    cmake
+    rocm-cmake
+  ];
+
+  buildInputs = [ libxml2 ];
+  cmakeFlags = [ "-DLLVM_TARGETS_TO_BUILD=AMDGPU;${llvmNativeTarget}" ];
+
+  passthru.updateScript = rocmUpdateScript {
+    name = finalAttrs.pname;
+    owner = finalAttrs.src.owner;
+    repo = finalAttrs.src.repo;
+  };
+
+  meta = with lib; {
+    description = "Set of AMD-specific device-side language runtime libraries";
+    homepage = "https://github.com/RadeonOpenCompute/ROCm-Device-Libs";
+    license = licenses.ncsa;
+    maintainers = with maintainers; [ lovesegfault ] ++ teams.rocm.members;
+    platforms = platforms.linux;
+    broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
+  };
+})
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/rocm-docs-core/default.nix b/nixpkgs/pkgs/development/rocm-modules/5/rocm-docs-core/default.nix
new file mode 100644
index 000000000000..65d21daa5b50
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/rocm-docs-core/default.nix
@@ -0,0 +1,65 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, gitUpdater
+, buildPythonPackage
+, setuptools
+, beautifulsoup4
+, gitpython
+, pydata-sphinx-theme
+, pygithub
+, sphinx
+, breathe
+, myst-parser
+, sphinx-book-theme
+, sphinx-copybutton
+, sphinx-design
+, sphinx-external-toc
+, sphinx-notfound-page
+, pyyaml
+, fastjsonschema
+}:
+
+buildPythonPackage rec {
+  pname = "rocm-docs-core";
+  version = "0.25.0";
+  format = "pyproject";
+
+  src = fetchFromGitHub {
+    owner = "RadeonOpenCompute";
+    repo = "rocm-docs-core";
+    rev = "v${version}";
+    hash = "sha256-kOsoIK0vaPT60hGr960s5vc0eloSr5CECtd8Dy24YuM=";
+  };
+
+  buildInputs = [ setuptools ];
+
+  propagatedBuildInputs = [
+    beautifulsoup4
+    gitpython
+    pydata-sphinx-theme
+    pygithub
+    sphinx
+    breathe
+    myst-parser
+    sphinx-book-theme
+    sphinx-copybutton
+    sphinx-design
+    sphinx-external-toc
+    sphinx-notfound-page
+    pyyaml
+    fastjsonschema
+  ];
+
+  pythonImportsCheck = [ "rocm_docs" ];
+
+  passthru.updateScript = gitUpdater { rev-prefix = "v"; };
+
+  meta = with lib; {
+    description = "ROCm Documentation Python package for ReadTheDocs build standardization";
+    homepage = "https://github.com/RadeonOpenCompute/rocm-docs-core";
+    license = with licenses; [ mit cc-by-40 ];
+    maintainers = teams.rocm.members;
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/rocm-runtime/default.nix b/nixpkgs/pkgs/development/rocm-modules/5/rocm-runtime/default.nix
new file mode 100644
index 000000000000..fd9182c8254d
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/rocm-runtime/default.nix
@@ -0,0 +1,78 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, rocmUpdateScript
+, pkg-config
+, cmake
+, xxd
+, rocm-device-libs
+, rocm-thunk
+, libelf
+, libdrm
+, numactl
+, valgrind
+, libxml2
+}:
+
+stdenv.mkDerivation (finalAttrs: {
+  pname = "rocm-runtime";
+  version = "5.7.0";
+
+  src = fetchFromGitHub {
+    owner = "RadeonOpenCompute";
+    repo = "ROCR-Runtime";
+    rev = "rocm-${finalAttrs.version}";
+    hash = "sha256-D7Ahan5cxDhqPtV5iDDNys0A4FlxQ9oVRa2EeMoY5Qk=";
+  };
+
+  sourceRoot = "${finalAttrs.src.name}/src";
+
+  nativeBuildInputs = [
+    pkg-config
+    cmake
+    xxd
+  ];
+
+  buildInputs = [
+    rocm-thunk
+    libelf
+    libdrm
+    numactl
+    valgrind
+    libxml2
+  ];
+
+  postPatch = ''
+    patchShebangs image/blit_src/create_hsaco_ascii_file.sh
+    patchShebangs core/runtime/trap_handler/create_trap_handler_header.sh
+
+    substituteInPlace CMakeLists.txt \
+      --replace 'hsa/include/hsa' 'include/hsa'
+
+    # We compile clang before rocm-device-libs, so patch it in afterwards
+    # Replace object version: https://github.com/RadeonOpenCompute/ROCR-Runtime/issues/166 (TODO: Remove on LLVM update?)
+    substituteInPlace image/blit_src/CMakeLists.txt \
+      --replace '-cl-denorms-are-zero' '-cl-denorms-are-zero --rocm-device-lib-path=${rocm-device-libs}/amdgcn/bitcode' \
+      --replace '-mcode-object-version=4' '-mcode-object-version=5'
+  '';
+
+  fixupPhase = ''
+    rm -rf $out/hsa/*
+    ln -s $out/{include,lib} $out/hsa
+  '';
+
+  passthru.updateScript = rocmUpdateScript {
+    name = finalAttrs.pname;
+    owner = finalAttrs.src.owner;
+    repo = finalAttrs.src.repo;
+  };
+
+  meta = with lib; {
+    description = "Platform runtime for ROCm";
+    homepage = "https://github.com/RadeonOpenCompute/ROCR-Runtime";
+    license = with licenses; [ ncsa ];
+    maintainers = with maintainers; [ lovesegfault ] ++ teams.rocm.members;
+    platforms = platforms.linux;
+    broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
+  };
+})
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/rocm-smi/cmake.patch b/nixpkgs/pkgs/development/rocm-modules/5/rocm-smi/cmake.patch
new file mode 100644
index 000000000000..2634ea46a1f8
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/rocm-smi/cmake.patch
@@ -0,0 +1,89 @@
+diff --git a/rocm_smi-backward-compat.cmake b/rocm_smi-backward-compat.cmake
+index aa8fd9c..59afce5 100644
+--- a/rocm_smi-backward-compat.cmake
++++ b/rocm_smi-backward-compat.cmake
+@@ -72,7 +72,12 @@ function(generate_wrapper_header)
+     set(include_guard "${include_guard}COMGR_WRAPPER_INCLUDE_${INC_GAURD_NAME}_H")
+     #set #include statement
+     get_filename_component(file_name ${header_file} NAME)
+-    set(include_statements "${include_statements}#include \"../../../${CMAKE_INSTALL_INCLUDEDIR}/${ROCM_SMI}/${file_name}\"\n")
++    if(IS_ABSOLUTE ${CMAKE_INSTALL_INCLUDEDIR})
++      set(include_dir "${CMAKE_INSTALL_INCLUDEDIR}")
++    else()
++      set(include_dir "../../../${CMAKE_INSTALL_INCLUDEDIR}")
++    endif()
++    set(include_statements "${include_statements}#include \"${include_dir}/${ROCM_SMI}/${file_name}\"\n")
+     configure_file(${RSMI_WRAPPER_DIR}/header.hpp.in ${RSMI_WRAPPER_INC_DIR}/${file_name})
+     unset(include_guard)
+     unset(include_statements)
+@@ -90,7 +95,12 @@ function(generate_wrapper_header)
+     set(include_guard "${include_guard}COMGR_WRAPPER_INCLUDE_${INC_GAURD_NAME}_H")
+     #set #include statement
+     get_filename_component(file_name ${header_file} NAME)
+-    set(include_statements "${include_statements}#include \"../../../${CMAKE_INSTALL_INCLUDEDIR}/${OAM_TARGET_NAME}/${file_name}\"\n")
++    if(IS_ABSOLUTE ${CMAKE_INSTALL_INCLUDEDIR})
++      set(include_dir "${CMAKE_INSTALL_INCLUDEDIR}")
++    else()
++      set(include_dir "../../../${CMAKE_INSTALL_INCLUDEDIR}")
++    endif()
++    set(include_statements "${include_statements}#include \"${include_dir}/${OAM_TARGET_NAME}/${file_name}\"\n")
+     configure_file(${RSMI_WRAPPER_DIR}/header.hpp.in ${OAM_WRAPPER_INC_DIR}/${file_name})
+     unset(include_guard)
+     unset(include_statements)
+@@ -123,11 +133,16 @@ function(create_library_symlink)
+     set(library_files "${LIB_RSMI}")
+   endif()
+ 
++  if(IS_ABSOLUTE ${CMAKE_INSTALL_LIBDIR})
++    set(install_libdir "${CMAKE_INSTALL_LIBDIR}")
++  else()
++    set(install_libdir "../../${CMAKE_INSTALL_LIBDIR}")
++  endif()
+   foreach(file_name ${library_files})
+      add_custom_target(link_${file_name} ALL
+                   WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+                   COMMAND ${CMAKE_COMMAND} -E create_symlink
+-                  ../../${CMAKE_INSTALL_LIBDIR}/${file_name} ${RSMI_WRAPPER_LIB_DIR}/${file_name})
++                  ${install_libdir}/${file_name} ${RSMI_WRAPPER_LIB_DIR}/${file_name})
+   endforeach()
+ 
+   file(MAKE_DIRECTORY ${OAM_WRAPPER_LIB_DIR})
+@@ -151,11 +166,16 @@ function(create_library_symlink)
+     set(library_files "${LIB_OAM}")
+   endif()
+ 
++  if(IS_ABSOLUTE ${CMAKE_INSTALL_LIBDIR})
++    set(install_libdir "${CMAKE_INSTALL_LIBDIR}")
++  else()
++    set(install_libdir "../../${CMAKE_INSTALL_LIBDIR}")
++  endif()
+   foreach(file_name ${library_files})
+      add_custom_target(link_${file_name} ALL
+                   WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+                   COMMAND ${CMAKE_COMMAND} -E create_symlink
+-                  ../../${CMAKE_INSTALL_LIBDIR}/${file_name} ${OAM_WRAPPER_LIB_DIR}/${file_name})
++                  ${install_libdir}/${file_name} ${OAM_WRAPPER_LIB_DIR}/${file_name})
+   endforeach()
+ 
+ endfunction()
+diff --git a/rocm_smi/CMakeLists.txt b/rocm_smi/CMakeLists.txt
+index c594eeb..d3ed39d 100755
+--- a/rocm_smi/CMakeLists.txt
++++ b/rocm_smi/CMakeLists.txt
+@@ -105,10 +105,15 @@ endif ()
+ #file reorganization changes
+ #rocm_smi.py moved to libexec/rocm_smi. so creating rocm-smi symlink
+ file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
++if(IS_ABSOLUTE ${CMAKE_INSTALL_LIBEXECDIR})
++  set(install_libexecdir "${CMAKE_INSTALL_LIBEXECDIR}")
++else()
++  set(install_libexecdir "../${CMAKE_INSTALL_LIBEXECDIR}")
++endif()
+ add_custom_target(link-rocm-smi ALL
+                   WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+                   COMMAND ${CMAKE_COMMAND} -E create_symlink
+-                  ../${CMAKE_INSTALL_LIBEXECDIR}/${ROCM_SMI}/rocm_smi.py ${CMAKE_CURRENT_BINARY_DIR}/bin/rocm-smi)
++                  ${install_libexecdir}/${ROCM_SMI}/rocm_smi.py ${CMAKE_CURRENT_BINARY_DIR}/bin/rocm-smi)
+ 
+ ## Add the install directives for the runtime library.
+ install(TARGETS ${ROCM_SMI_TARGET}
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/rocm-smi/default.nix b/nixpkgs/pkgs/development/rocm-modules/5/rocm-smi/default.nix
new file mode 100644
index 000000000000..2e1692539e23
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/rocm-smi/default.nix
@@ -0,0 +1,54 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, rocmUpdateScript
+, cmake
+, wrapPython
+}:
+
+stdenv.mkDerivation (finalAttrs: {
+  pname = "rocm-smi";
+  version = "5.7.0";
+
+  src = fetchFromGitHub {
+    owner = "RadeonOpenCompute";
+    repo = "rocm_smi_lib";
+    rev = "rocm-${finalAttrs.version}";
+    hash = "sha256-swCRO4PBMBJ6fO2bLq/xxFZIYw2IgiFB490wsU8Wm2o=";
+  };
+
+  patches = [ ./cmake.patch ];
+
+  nativeBuildInputs = [
+    cmake
+    wrapPython
+  ];
+
+  cmakeFlags = [
+    # Manually define CMAKE_INSTALL_<DIR>
+    # See: https://github.com/NixOS/nixpkgs/pull/197838
+    "-DCMAKE_INSTALL_BINDIR=bin"
+    "-DCMAKE_INSTALL_LIBDIR=lib"
+    "-DCMAKE_INSTALL_INCLUDEDIR=include"
+  ];
+
+  postInstall = ''
+    wrapPythonProgramsIn $out
+    mv $out/libexec/rocm_smi/.rsmiBindings.py-wrapped $out/libexec/rocm_smi/rsmiBindings.py
+  '';
+
+  passthru.updateScript = rocmUpdateScript {
+    name = finalAttrs.pname;
+    owner = finalAttrs.src.owner;
+    repo = finalAttrs.src.repo;
+  };
+
+  meta = with lib; {
+    description = "System management interface for AMD GPUs supported by ROCm";
+    homepage = "https://github.com/RadeonOpenCompute/rocm_smi_lib";
+    license = with licenses; [ mit ];
+    maintainers = with maintainers; [ lovesegfault ] ++ teams.rocm.members;
+    platforms = [ "x86_64-linux" ];
+    broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
+  };
+})
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/rocm-thunk/default.nix b/nixpkgs/pkgs/development/rocm-modules/5/rocm-thunk/default.nix
new file mode 100644
index 000000000000..73368dbb0e7f
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/rocm-thunk/default.nix
@@ -0,0 +1,54 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, rocmUpdateScript
+, pkg-config
+, cmake
+, libdrm
+, numactl
+}:
+
+stdenv.mkDerivation (finalAttrs: {
+  pname = "rocm-thunk";
+  version = "5.7.0";
+
+  src = fetchFromGitHub {
+    owner = "RadeonOpenCompute";
+    repo = "ROCT-Thunk-Interface";
+    rev = "rocm-${finalAttrs.version}";
+    hash = "sha256-jAMBks2/JaXiA45B3qvLHY8fPeFcr1GHT5Jieuduqhw=";
+  };
+
+  nativeBuildInputs = [
+    pkg-config
+    cmake
+  ];
+
+  buildInputs = [
+    libdrm
+    numactl
+  ];
+
+  cmakeFlags = [
+    # Manually define CMAKE_INSTALL_<DIR>
+    # See: https://github.com/NixOS/nixpkgs/pull/197838
+    "-DCMAKE_INSTALL_BINDIR=bin"
+    "-DCMAKE_INSTALL_LIBDIR=lib"
+    "-DCMAKE_INSTALL_INCLUDEDIR=include"
+  ];
+
+  passthru.updateScript = rocmUpdateScript {
+    name = finalAttrs.pname;
+    owner = finalAttrs.src.owner;
+    repo = finalAttrs.src.repo;
+  };
+
+  meta = with lib; {
+    description = "Radeon open compute thunk interface";
+    homepage = "https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface";
+    license = with licenses; [ bsd2 mit ];
+    maintainers = with maintainers; [ lovesegfault ] ++ teams.rocm.members;
+    platforms = platforms.linux;
+    broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
+  };
+})
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/rocminfo/default.nix b/nixpkgs/pkgs/development/rocm-modules/5/rocminfo/default.nix
new file mode 100644
index 000000000000..c9ff79e380ff
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/rocminfo/default.nix
@@ -0,0 +1,63 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, rocmUpdateScript
+, cmake
+, rocm-cmake
+, rocm-runtime
+, busybox
+, python3
+, gnugrep
+  # rocminfo requires that the calling user have a password and be in
+  # the video group. If we let rocm_agent_enumerator rely upon
+  # rocminfo's output, then it, too, has those requirements. Instead,
+  # we can specify the GPU targets for this system (e.g. "gfx803" for
+  # Polaris) such that no system call is needed for downstream
+  # compilers to determine the desired target.
+, defaultTargets ? []
+}:
+
+stdenv.mkDerivation (finalAttrs: {
+  version = "5.7.0";
+  pname = "rocminfo";
+
+  src = fetchFromGitHub {
+    owner = "RadeonOpenCompute";
+    repo = "rocminfo";
+    rev = "rocm-${finalAttrs.version}";
+    sha256 = "sha256-UzOo2qDT/uM+vdGdBM4pV5e143mfa+/6sZLBExOO26g=";
+  };
+
+  nativeBuildInputs = [
+    cmake
+    rocm-cmake
+  ];
+
+  buildInputs = [ rocm-runtime ];
+  propagatedBuildInputs = [ python3 ];
+  cmakeFlags = [ "-DROCRTST_BLD_TYPE=Release" ];
+
+  prePatch = ''
+    patchShebangs rocm_agent_enumerator
+    sed 's,lsmod | grep ,${busybox}/bin/lsmod | ${gnugrep}/bin/grep ,' -i rocminfo.cc
+  '';
+
+  postInstall = lib.optionalString (defaultTargets != [ ]) ''
+    echo '${lib.concatStringsSep "\n" defaultTargets}' > $out/bin/target.lst
+  '';
+
+  passthru.updateScript = rocmUpdateScript {
+    name = finalAttrs.pname;
+    owner = finalAttrs.src.owner;
+    repo = finalAttrs.src.repo;
+  };
+
+  meta = with lib; {
+    description = "ROCm Application for Reporting System Info";
+    homepage = "https://github.com/RadeonOpenCompute/rocminfo";
+    license = licenses.ncsa;
+    maintainers = with maintainers; [ lovesegfault ] ++ teams.rocm.members;
+    platforms = platforms.linux;
+    broken = stdenv.isAarch64 || versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
+  };
+})
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/rocmlir/default.nix b/nixpkgs/pkgs/development/rocm-modules/5/rocmlir/default.nix
new file mode 100644
index 000000000000..9b24112dce8a
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/rocmlir/default.nix
@@ -0,0 +1,130 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, rocmUpdateScript
+, cmake
+, rocm-cmake
+, ninja
+, clr
+, git
+, libxml2
+, libedit
+, zstd
+, zlib
+, ncurses
+, python3Packages
+, buildRockCompiler ? false
+, buildTests ? false # `argument of type 'NoneType' is not iterable`
+}:
+
+# Theoretically, we could have our MLIR have an output
+# with the source and built objects so that we can just
+# use it as the external LLVM repo for this
+let
+  suffix =
+    if buildRockCompiler
+    then "-rock"
+    else "";
+
+  llvmNativeTarget =
+    if stdenv.isx86_64 then "X86"
+    else if stdenv.isAarch64 then "AArch64"
+    else throw "Unsupported ROCm LLVM platform";
+in stdenv.mkDerivation (finalAttrs: {
+  pname = "rocmlir${suffix}";
+  version = "5.7.0";
+
+  outputs = [
+    "out"
+  ] ++ lib.optionals (!buildRockCompiler) [
+    "external"
+  ];
+
+  src = fetchFromGitHub {
+    owner = "ROCmSoftwarePlatform";
+    repo = "rocMLIR";
+    rev = "rocm-${finalAttrs.version}";
+    hash = "sha256-vPi4UVljohVAfnwDVQqeOVaJPa6v8aV5uBOtqLddTtc=";
+  };
+
+  nativeBuildInputs = [
+    cmake
+    rocm-cmake
+    ninja
+    clr
+    python3Packages.python
+    python3Packages.tomli
+  ];
+
+  buildInputs = [
+    git
+    libxml2
+    libedit
+  ];
+
+  propagatedBuildInputs = [
+    zstd
+    zlib
+    ncurses
+  ];
+
+  cmakeFlags = [
+    "-DLLVM_TARGETS_TO_BUILD=AMDGPU;${llvmNativeTarget}"
+    "-DLLVM_ENABLE_ZSTD=ON"
+    "-DLLVM_ENABLE_ZLIB=ON"
+    "-DLLVM_ENABLE_TERMINFO=ON"
+    "-DROCM_PATH=${clr}"
+    # Manually define CMAKE_INSTALL_<DIR>
+    # See: https://github.com/NixOS/nixpkgs/pull/197838
+    "-DCMAKE_INSTALL_BINDIR=bin"
+    "-DCMAKE_INSTALL_LIBDIR=lib"
+    "-DCMAKE_INSTALL_INCLUDEDIR=include"
+  ] ++ lib.optionals buildRockCompiler [
+    "-DBUILD_FAT_LIBROCKCOMPILER=ON"
+  ] ++ lib.optionals (!buildRockCompiler) [
+    "-DROCM_TEST_CHIPSET=gfx000"
+  ];
+
+  postPatch = ''
+    patchShebangs mlir
+
+    substituteInPlace mlir/utils/performance/common/CMakeLists.txt \
+      --replace "/opt/rocm" "${clr}"
+  '';
+
+  dontBuild = true;
+  doCheck = true;
+
+  # Certain libs aren't being generated, try enabling tests next update
+  checkTarget = if buildRockCompiler
+                then "librockCompiler"
+                else if buildTests
+                then "check-rocmlir"
+                else "check-rocmlir-build-only";
+
+  postInstall = let
+    libPath = lib.makeLibraryPath [ zstd zlib ncurses clr stdenv.cc.cc ];
+  in lib.optionals (!buildRockCompiler) ''
+    mkdir -p $external/lib
+    cp -a external/llvm-project/llvm/lib/{*.a*,*.so*} $external/lib
+    patchelf --set-rpath $external/lib:$out/lib:${libPath} $external/lib/*.so*
+    patchelf --set-rpath $out/lib:$external/lib:${libPath} $out/{bin/*,lib/*.so*}
+  '';
+
+  passthru.updateScript = rocmUpdateScript {
+    name = finalAttrs.pname;
+    owner = finalAttrs.src.owner;
+    repo = finalAttrs.src.repo;
+    page = "tags?per_page=2";
+    filter = ".[1].name | split(\"-\") | .[1]";
+  };
+
+  meta = with lib; {
+    description = "MLIR-based convolution and GEMM kernel generator";
+    homepage = "https://github.com/ROCmSoftwarePlatform/rocMLIR";
+    license = with licenses; [ asl20 ];
+    maintainers = teams.rocm.members;
+    platforms = platforms.linux;
+    broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
+  };
+})
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/rocprim/default.nix b/nixpkgs/pkgs/development/rocm-modules/5/rocprim/default.nix
new file mode 100644
index 000000000000..1dd2555c6915
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/rocprim/default.nix
@@ -0,0 +1,86 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, rocmUpdateScript
+, cmake
+, rocm-cmake
+, clr
+, gtest
+, gbenchmark
+, buildTests ? false
+, buildBenchmarks ? false
+, gpuTargets ? [ ]
+}:
+
+stdenv.mkDerivation (finalAttrs: {
+  pname = "rocprim";
+  version = "5.7.0";
+
+  outputs = [
+    "out"
+  ] ++ lib.optionals buildTests [
+    "test"
+  ] ++ lib.optionals buildBenchmarks [
+    "benchmark"
+  ];
+
+  src = fetchFromGitHub {
+    owner = "ROCmSoftwarePlatform";
+    repo = "rocPRIM";
+    rev = "rocm-${finalAttrs.version}";
+    hash = "sha256-+ukFWsWv3RhS+Z6tmR4TRT8QTYEDuAEk12F9Gv1eXGU=";
+  };
+
+  nativeBuildInputs = [
+    cmake
+    rocm-cmake
+    clr
+  ];
+
+  buildInputs = lib.optionals buildTests [
+    gtest
+  ] ++ lib.optionals buildBenchmarks [
+    gbenchmark
+  ];
+
+  cmakeFlags = [
+    "-DCMAKE_CXX_COMPILER=hipcc"
+    # Manually define CMAKE_INSTALL_<DIR>
+    # See: https://github.com/NixOS/nixpkgs/pull/197838
+    "-DCMAKE_INSTALL_BINDIR=bin"
+    "-DCMAKE_INSTALL_LIBDIR=lib"
+    "-DCMAKE_INSTALL_INCLUDEDIR=include"
+  ] ++ lib.optionals (gpuTargets != [ ]) [
+    "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}"
+  ] ++ lib.optionals buildTests [
+    "-DBUILD_TEST=ON"
+  ] ++ lib.optionals buildBenchmarks [
+    "-DBUILD_BENCHMARK=ON"
+  ];
+
+  postInstall = lib.optionalString buildTests ''
+    mkdir -p $test/bin
+    mv $out/bin/test_* $test/bin
+    mv $out/bin/rocprim $test/bin
+  '' + lib.optionalString buildBenchmarks ''
+    mkdir -p $benchmark/bin
+    mv $out/bin/benchmark_* $benchmark/bin
+  '' + lib.optionalString (buildTests || buildBenchmarks) ''
+    rmdir $out/bin
+  '';
+
+  passthru.updateScript = rocmUpdateScript {
+    name = finalAttrs.pname;
+    owner = finalAttrs.src.owner;
+    repo = finalAttrs.src.repo;
+  };
+
+  meta = with lib; {
+    description = "ROCm parallel primitives";
+    homepage = "https://github.com/ROCmSoftwarePlatform/rocPRIM";
+    license = with licenses; [ mit ];
+    maintainers = teams.rocm.members;
+    platforms = platforms.linux;
+    broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
+  };
+})
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/rocprofiler/default.nix b/nixpkgs/pkgs/development/rocm-modules/5/rocprofiler/default.nix
new file mode 100644
index 000000000000..ec24a3f41e59
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/rocprofiler/default.nix
@@ -0,0 +1,108 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, rocmUpdateScript
+, cmake
+, clang
+, clr
+, rocm-thunk
+, roctracer
+, rocm-smi
+, hsa-amd-aqlprofile-bin
+, numactl
+, libpciaccess
+, libxml2
+, elfutils
+, mpi
+, gtest
+, python3Packages
+, gpuTargets ? [
+  "gfx900"
+  "gfx906"
+  "gfx908"
+  "gfx90a"
+  "gfx940"
+  "gfx941"
+  "gfx942"
+  "gfx1030"
+  "gfx1100"
+  "gfx1101"
+  "gfx1102"
+]
+}:
+
+stdenv.mkDerivation (finalAttrs: {
+  pname = "rocprofiler";
+  version = "5.7.0";
+
+  src = fetchFromGitHub {
+    owner = "ROCm-Developer-Tools";
+    repo = "rocprofiler";
+    rev = "rocm-${finalAttrs.version}";
+    hash = "sha256-ue/2uiLbhOv/5XY4cIJuZ8DUMRhniYgxolq9xMwO1FY=";
+  };
+
+  nativeBuildInputs = [
+    cmake
+    clang
+    clr
+    python3Packages.lxml
+    python3Packages.cppheaderparser
+    python3Packages.pyyaml
+    python3Packages.barectf
+  ];
+
+  buildInputs = [
+    rocm-thunk
+    rocm-smi
+    hsa-amd-aqlprofile-bin
+    numactl
+    libpciaccess
+    libxml2
+    elfutils
+    mpi
+    gtest
+  ];
+
+  cmakeFlags = [
+    "-DCMAKE_MODULE_PATH=${clr}/lib/cmake/hip"
+    "-DPROF_API_HEADER_PATH=${roctracer.src}/inc/ext"
+    "-DHIP_ROOT_DIR=${clr}"
+    "-DGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}"
+    # Manually define CMAKE_INSTALL_<DIR>
+    # See: https://github.com/NixOS/nixpkgs/pull/197838
+    "-DCMAKE_INSTALL_BINDIR=bin"
+    "-DCMAKE_INSTALL_LIBDIR=lib"
+    "-DCMAKE_INSTALL_INCLUDEDIR=include"
+  ];
+
+  postPatch = ''
+    patchShebangs .
+
+    # Cannot find ROCm device library, pointless
+    substituteInPlace CMakeLists.txt \
+      --replace "add_subdirectory(tests-v2)" "" \
+      --replace "add_subdirectory(samples)" ""
+  '';
+
+  postBuild = ''
+    # HSACO aren't being built for some reason
+    substituteInPlace test/cmake_install.cmake \
+      --replace "file(INSTALL DESTINATION \"\''${CMAKE_INSTALL_PREFIX}/share/rocprofiler/tests-v1\" TYPE FILE FILES \"" "message(\""
+  '';
+
+  passthru.updateScript = rocmUpdateScript {
+    name = finalAttrs.pname;
+    owner = finalAttrs.src.owner;
+    repo = finalAttrs.src.repo;
+  };
+
+  meta = with lib; {
+    description = "Profiling with perf-counters and derived metrics";
+    homepage = "https://github.com/ROCm-Developer-Tools/rocprofiler";
+    license = with licenses; [ mit ]; # mitx11
+    maintainers = teams.rocm.members;
+    platforms = platforms.linux;
+    broken = versions.minor finalAttrs.version != versions.minor clr.version;
+  };
+})
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/rocr-debug-agent/default.nix b/nixpkgs/pkgs/development/rocm-modules/5/rocr-debug-agent/default.nix
new file mode 100644
index 000000000000..dfc8580b3e14
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/rocr-debug-agent/default.nix
@@ -0,0 +1,59 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, rocmUpdateScript
+, cmake
+, clr
+, git
+, rocdbgapi
+, elfutils
+}:
+
+stdenv.mkDerivation (finalAttrs: {
+  pname = "rocr-debug-agent";
+  version = "5.7.0";
+
+  src = fetchFromGitHub {
+    owner = "ROCm-Developer-Tools";
+    repo = "rocr_debug_agent";
+    rev = "rocm-${finalAttrs.version}";
+    hash = "sha256-AUDbNrFtUQ5Hm+uv5KMovh7P9wXQKLyRNx9gEQFnv6Y=";
+  };
+
+  nativeBuildInputs = [
+    cmake
+    clr
+    git
+  ];
+
+  buildInputs = [
+    rocdbgapi
+    elfutils
+  ];
+
+  cmakeFlags = [
+    "-DCMAKE_MODULE_PATH=${clr}/lib/cmake/hip"
+    "-DHIP_ROOT_DIR=${clr}"
+    "-DHIP_PATH=${clr}"
+  ];
+
+  # Weird install target
+  postInstall = ''
+    rm -rf $out/src
+  '';
+
+  passthru.updateScript = rocmUpdateScript {
+    name = finalAttrs.pname;
+    owner = finalAttrs.src.owner;
+    repo = finalAttrs.src.repo;
+  };
+
+  meta = with lib; {
+    description = "Library that provides some debugging functionality for ROCr";
+    homepage = "https://github.com/ROCm-Developer-Tools/rocr_debug_agent";
+    license = with licenses; [ ncsa ];
+    maintainers = teams.rocm.members;
+    platforms = platforms.linux;
+    broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
+  };
+})
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/rocrand/default.nix b/nixpkgs/pkgs/development/rocm-modules/5/rocrand/default.nix
new file mode 100644
index 000000000000..954a299e317e
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/rocrand/default.nix
@@ -0,0 +1,88 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, rocmUpdateScript
+, cmake
+, rocm-cmake
+, clr
+, gtest
+, gbenchmark
+, buildTests ? false
+, buildBenchmarks ? false
+, gpuTargets ? [ ]
+}:
+
+stdenv.mkDerivation (finalAttrs: {
+  pname = "rocrand";
+  version = "5.7.0";
+
+  outputs = [
+    "out"
+  ] ++ lib.optionals buildTests [
+    "test"
+  ] ++ lib.optionals buildBenchmarks [
+    "benchmark"
+  ];
+
+  src = fetchFromGitHub {
+    owner = "ROCmSoftwarePlatform";
+    repo = "rocRAND";
+    rev = "rocm-${finalAttrs.version}";
+    hash = "sha256-cFH38fLD8tk6V9JERcqHokuwKemdDgHCZ75bZNEqmdY=";
+    fetchSubmodules = true; # For inline hipRAND
+  };
+
+  nativeBuildInputs = [
+    cmake
+    rocm-cmake
+    clr
+  ];
+
+  buildInputs = lib.optionals buildTests [
+    gtest
+  ] ++ lib.optionals buildBenchmarks [
+    gbenchmark
+  ];
+
+  cmakeFlags = [
+    "-DCMAKE_C_COMPILER=hipcc"
+    "-DCMAKE_CXX_COMPILER=hipcc"
+    "-DHIP_ROOT_DIR=${clr}"
+    # Manually define CMAKE_INSTALL_<DIR>
+    # See: https://github.com/NixOS/nixpkgs/pull/197838
+    "-DCMAKE_INSTALL_BINDIR=bin"
+    "-DCMAKE_INSTALL_LIBDIR=lib"
+    "-DCMAKE_INSTALL_INCLUDEDIR=include"
+  ] ++ lib.optionals (gpuTargets != [ ]) [
+    "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}"
+  ] ++ lib.optionals buildTests [
+    "-DBUILD_TEST=ON"
+  ] ++ lib.optionals buildBenchmarks [
+    "-DBUILD_BENCHMARK=ON"
+  ];
+
+  postInstall = lib.optionalString buildTests ''
+    mkdir -p $test/bin
+    mv $out/bin/test_* $test/bin
+  '' + lib.optionalString buildBenchmarks ''
+    mkdir -p $benchmark/bin
+    mv $out/bin/benchmark_* $benchmark/bin
+  '' + lib.optionalString (buildTests || buildBenchmarks) ''
+    rmdir $out/bin
+  '';
+
+  passthru.updateScript = rocmUpdateScript {
+    name = finalAttrs.pname;
+    owner = finalAttrs.src.owner;
+    repo = finalAttrs.src.repo;
+  };
+
+  meta = with lib; {
+    description = "Generate pseudo-random and quasi-random numbers";
+    homepage = "https://github.com/ROCmSoftwarePlatform/rocRAND";
+    license = with licenses; [ mit ];
+    maintainers = teams.rocm.members;
+    platforms = platforms.linux;
+    broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
+  };
+})
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/rocsolver/default.nix b/nixpkgs/pkgs/development/rocm-modules/5/rocsolver/default.nix
new file mode 100644
index 000000000000..6490870ea48a
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/rocsolver/default.nix
@@ -0,0 +1,100 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, rocmUpdateScript
+, cmake
+, rocm-cmake
+, rocblas
+, rocsparse
+, clr
+, fmt
+, gtest
+, gfortran
+, lapack-reference
+, buildTests ? false
+, buildBenchmarks ? false
+, gpuTargets ? [ ] # gpuTargets = [ "gfx803" "gfx900" "gfx906:xnack-" ]
+}:
+
+stdenv.mkDerivation (finalAttrs: {
+  pname = "rocsolver";
+  version = "5.7.0";
+
+  outputs = [
+    "out"
+  ] ++ lib.optionals buildTests [
+    "test"
+  ] ++ lib.optionals buildBenchmarks [
+    "benchmark"
+  ];
+
+  src = fetchFromGitHub {
+    owner = "ROCmSoftwarePlatform";
+    repo = "rocSOLVER";
+    rev = "rocm-${finalAttrs.version}";
+    hash = "sha256-qxmjm4tgpCnfJ2SqUXndk6y0MsPJUKHvjv/3Uc0smr4=";
+  };
+
+  nativeBuildInputs = [
+    cmake
+    rocm-cmake
+    clr
+  ] ++ lib.optionals (buildTests || buildBenchmarks) [
+    gfortran
+  ];
+
+  buildInputs = [
+    rocblas
+    rocsparse
+    fmt
+  ] ++ lib.optionals buildTests [
+    gtest
+  ] ++ lib.optionals (buildTests || buildBenchmarks) [
+    lapack-reference
+  ];
+
+  cmakeFlags = [
+    "-DCMAKE_CXX_COMPILER=hipcc"
+    "-DCMAKE_CXX_FLAGS=-Wno-switch" # Way too many warnings
+    # Manually define CMAKE_INSTALL_<DIR>
+    # See: https://github.com/NixOS/nixpkgs/pull/197838
+    "-DCMAKE_INSTALL_BINDIR=bin"
+    "-DCMAKE_INSTALL_LIBDIR=lib"
+    "-DCMAKE_INSTALL_INCLUDEDIR=include"
+  ] ++ lib.optionals (gpuTargets != [ ]) [
+    "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}"
+  ] ++ lib.optionals buildTests [
+    "-DBUILD_CLIENTS_TESTS=ON"
+  ] ++ lib.optionals buildBenchmarks [
+    "-DBUILD_CLIENTS_BENCHMARKS=ON"
+  ];
+
+  postInstall = lib.optionalString buildTests ''
+    mkdir -p $test/bin
+    mv $out/bin/rocsolver-test $test/bin
+  '' + lib.optionalString buildBenchmarks ''
+    mkdir -p $benchmark/bin
+    mv $out/bin/rocsolver-bench $benchmark/bin
+  '' + lib.optionalString (buildTests || buildBenchmarks) ''
+    rmdir $out/bin
+  '';
+
+  passthru.updateScript = rocmUpdateScript {
+    name = finalAttrs.pname;
+    owner = finalAttrs.src.owner;
+    repo = finalAttrs.src.repo;
+  };
+
+  requiredSystemFeatures = [ "big-parallel" ];
+
+  meta = with lib; {
+    description = "ROCm LAPACK implementation";
+    homepage = "https://github.com/ROCmSoftwarePlatform/rocSOLVER";
+    license = with licenses; [ bsd2 ];
+    maintainers = teams.rocm.members;
+    platforms = platforms.linux;
+    timeout = 14400; # 4 hours
+    maxSilent = 14400; # 4 hours
+    broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
+  };
+})
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/rocsparse/default.nix b/nixpkgs/pkgs/development/rocm-modules/5/rocsparse/default.nix
new file mode 100644
index 000000000000..945e03c0bc8b
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/rocsparse/default.nix
@@ -0,0 +1,149 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, fetchzip
+, rocmUpdateScript
+, cmake
+, rocm-cmake
+, rocprim
+, clr
+, gfortran
+, git
+, gtest
+, boost
+, python3Packages
+, buildTests ? false
+, buildBenchmarks ? false # Seems to depend on tests
+, gpuTargets ? [ ]
+}:
+
+stdenv.mkDerivation (finalAttrs: {
+  pname = "rocsparse";
+  version = "5.7.0";
+
+  outputs = [
+    "out"
+  ] ++ lib.optionals (buildTests || buildBenchmarks) [
+    "test"
+  ] ++ lib.optionals buildBenchmarks [
+    "benchmark"
+  ];
+
+  src = fetchFromGitHub {
+    owner = "ROCmSoftwarePlatform";
+    repo = "rocSPARSE";
+    rev = "rocm-${finalAttrs.version}";
+    hash = "sha256-30q9bqgZJUaNrkMXTAG+Z34yjsQ5DpJP+WBcCiEmF58=";
+  };
+
+  nativeBuildInputs = [
+    cmake
+    rocm-cmake
+    clr
+    gfortran
+  ];
+
+  buildInputs = [
+    rocprim
+    git
+  ] ++ lib.optionals (buildTests || buildBenchmarks) [
+    gtest
+    boost
+    python3Packages.python
+    python3Packages.pyyaml
+  ];
+
+  cmakeFlags = [
+    "-DCMAKE_CXX_COMPILER=hipcc"
+    # Manually define CMAKE_INSTALL_<DIR>
+    # See: https://github.com/NixOS/nixpkgs/pull/197838
+    "-DCMAKE_INSTALL_BINDIR=bin"
+    "-DCMAKE_INSTALL_LIBDIR=lib"
+    "-DCMAKE_INSTALL_INCLUDEDIR=include"
+  ] ++ lib.optionals (gpuTargets != [ ]) [
+    "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}"
+  ] ++ lib.optionals (buildTests || buildBenchmarks) [
+    "-DBUILD_CLIENTS_TESTS=ON"
+    "-DCMAKE_MATRICES_DIR=/build/source/matrices"
+    "-Dpython=python3"
+  ] ++ lib.optionals buildBenchmarks [
+    "-DBUILD_CLIENTS_BENCHMARKS=ON"
+  ];
+
+  # We have to manually generate the matrices
+  postPatch = lib.optionalString (buildTests || buildBenchmarks) ''
+    mkdir -p matrices
+
+    ln -s ${finalAttrs.passthru.matrices.matrix-01}/*.mtx matrices
+    ln -s ${finalAttrs.passthru.matrices.matrix-02}/*.mtx matrices
+    ln -s ${finalAttrs.passthru.matrices.matrix-03}/*.mtx matrices
+    ln -s ${finalAttrs.passthru.matrices.matrix-04}/*.mtx matrices
+    ln -s ${finalAttrs.passthru.matrices.matrix-05}/*.mtx matrices
+    ln -s ${finalAttrs.passthru.matrices.matrix-06}/*.mtx matrices
+    ln -s ${finalAttrs.passthru.matrices.matrix-07}/*.mtx matrices
+    ln -s ${finalAttrs.passthru.matrices.matrix-08}/*.mtx matrices
+    ln -s ${finalAttrs.passthru.matrices.matrix-09}/*.mtx matrices
+    ln -s ${finalAttrs.passthru.matrices.matrix-10}/*.mtx matrices
+    ln -s ${finalAttrs.passthru.matrices.matrix-11}/*.mtx matrices
+    ln -s ${finalAttrs.passthru.matrices.matrix-12}/*.mtx matrices
+    ln -s ${finalAttrs.passthru.matrices.matrix-13}/*.mtx matrices
+    ln -s ${finalAttrs.passthru.matrices.matrix-14}/*.mtx matrices
+    ln -s ${finalAttrs.passthru.matrices.matrix-15}/*.mtx matrices
+    ln -s ${finalAttrs.passthru.matrices.matrix-16}/*.mtx matrices
+    ln -s ${finalAttrs.passthru.matrices.matrix-17}/*.mtx matrices
+    ln -s ${finalAttrs.passthru.matrices.matrix-18}/*.mtx matrices
+    ln -s ${finalAttrs.passthru.matrices.matrix-19}/*.mtx matrices
+    ln -s ${finalAttrs.passthru.matrices.matrix-20}/*.mtx matrices
+    ln -s ${finalAttrs.passthru.matrices.matrix-21}/*.mtx matrices
+    ln -s ${finalAttrs.passthru.matrices.matrix-22}/*.mtx matrices
+    ln -s ${finalAttrs.passthru.matrices.matrix-23}/*.mtx matrices
+    ln -s ${finalAttrs.passthru.matrices.matrix-24}/*.mtx matrices
+
+    # Not used by the original cmake, causes an error
+    rm matrices/*_b.mtx
+
+    echo "deps/convert.cpp -> deps/mtx2csr"
+    hipcc deps/convert.cpp -O3 -o deps/mtx2csr
+
+    for mat in $(ls -1 matrices | cut -d "." -f 1); do
+      echo "mtx2csr: $mat.mtx -> $mat.csr"
+      deps/mtx2csr matrices/$mat.mtx matrices/$mat.csr
+      unlink matrices/$mat.mtx
+    done
+  '';
+
+  postInstall = lib.optionalString buildBenchmarks ''
+    mkdir -p $benchmark/bin
+    cp -a $out/bin/* $benchmark/bin
+    rm $benchmark/bin/rocsparse-test
+  '' + lib.optionalString (buildTests || buildBenchmarks) ''
+    mkdir -p $test/bin
+    mv $out/bin/* $test/bin
+    rm $test/bin/rocsparse-bench || true
+    mv /build/source/matrices $test
+    rmdir $out/bin
+  '';
+
+  passthru = {
+    matrices = import ./deps.nix {
+      inherit fetchzip;
+      mirror1 = "https://sparse.tamu.edu/MM";
+      mirror2 = "https://www.cise.ufl.edu/research/sparse/MM";
+    };
+
+    updateScript = rocmUpdateScript {
+      name = finalAttrs.pname;
+      owner = finalAttrs.src.owner;
+      repo = finalAttrs.src.repo;
+    };
+  };
+
+  meta = with lib; {
+    description = "ROCm SPARSE implementation";
+    homepage = "https://github.com/ROCmSoftwarePlatform/rocSPARSE";
+    license = with licenses; [ mit ];
+    maintainers = teams.rocm.members;
+    platforms = platforms.linux;
+    broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
+  };
+})
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/rocsparse/deps.nix b/nixpkgs/pkgs/development/rocm-modules/5/rocsparse/deps.nix
new file mode 100644
index 000000000000..cef880ab3232
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/rocsparse/deps.nix
@@ -0,0 +1,222 @@
+{ fetchzip
+, mirror1
+, mirror2
+}:
+
+{
+  matrix-01 = fetchzip {
+    sha256 = "sha256-AHur5ZIDZTFRrO2GV0ieXrffq4KUiGWiZ59pv0fUtEQ=";
+
+    urls = [
+      "${mirror1}/SNAP/amazon0312.tar.gz"
+      "${mirror2}/SNAP/amazon0312.tar.gz"
+    ];
+  };
+
+  matrix-02 = fetchzip {
+    sha256 = "sha256-0rSxaN4lQcdaCLsvlgicG70FXUxXeERPiEmQ4MzbRdE=";
+
+    urls = [
+      "${mirror1}/Muite/Chebyshev4.tar.gz"
+      "${mirror2}/Muite/Chebyshev4.tar.gz"
+    ];
+  };
+
+  matrix-03 = fetchzip {
+    sha256 = "sha256-hDzDWDUnHEyFedX/tMNq83ZH8uWyM4xtZYUUAD3rizo=";
+
+    urls = [
+      "${mirror1}/FEMLAB/sme3Dc.tar.gz"
+      "${mirror2}/FEMLAB/sme3Dc.tar.gz"
+    ];
+  };
+
+  matrix-04 = fetchzip {
+    sha256 = "sha256-GmN2yOt/MoX01rKe05aTyB3ypUP4YbQGOITZ0BqPmC0=";
+
+    urls = [
+      "${mirror1}/Williams/webbase-1M.tar.gz"
+      "${mirror2}/Williams/webbase-1M.tar.gz"
+    ];
+  };
+
+  matrix-05 = fetchzip {
+    sha256 = "sha256-gQNjfVyWzNM9RwImJGhkhahRmZz74LzDs1oijL7mI7k=";
+
+    urls = [
+      "${mirror1}/Williams/mac_econ_fwd500.tar.gz"
+      "${mirror2}/Williams/mac_econ_fwd500.tar.gz"
+    ];
+  };
+
+  matrix-06 = fetchzip {
+    sha256 = "sha256-87cdZjntNcTuz5BtO59irhcuRbPllWSbhCEX3Td02qc=";
+
+    urls = [
+      "${mirror1}/Williams/mc2depi.tar.gz"
+      "${mirror2}/Williams/mc2depi.tar.gz"
+    ];
+  };
+
+  matrix-07 = fetchzip {
+    sha256 = "sha256-WRamuJX3D8Tm+k0q67RjUDG3DeNAxhKiaPkk5afY5eU=";
+
+    urls = [
+      "${mirror1}/Bova/rma10.tar.gz"
+      "${mirror2}/Bova/rma10.tar.gz"
+    ];
+  };
+
+  matrix-08 = fetchzip {
+    sha256 = "sha256-5dhkm293Mc3lzakKxHy5W5XIn4Rw+gihVh7gyrjEHXo=";
+
+    urls = [
+      "${mirror1}/JGD_BIBD/bibd_22_8.tar.gz"
+      "${mirror2}/JGD_BIBD/bibd_22_8.tar.gz"
+    ];
+  };
+
+  matrix-09 = fetchzip {
+    sha256 = "sha256-czjLWCjXAjZCk5TGYHaEkwSAzQu3TQ3QyB6eNKR4G88=";
+
+    urls = [
+      "${mirror1}/Hamm/scircuit.tar.gz"
+      "${mirror2}/Hamm/scircuit.tar.gz"
+    ];
+  };
+
+  matrix-10 = fetchzip {
+    sha256 = "sha256-bYuLnJViAIcIejAkh69/bsNAVIDU4wfTLtD+nmHd6FM=";
+
+    urls = [
+      "${mirror1}/Sandia/ASIC_320k.tar.gz"
+      "${mirror2}/Sandia/ASIC_320k.tar.gz"
+    ];
+  };
+
+  matrix-11 = fetchzip {
+    sha256 = "sha256-aDwn8P1khYjo2Agbq5m9ZBInJUxf/knJNvyptt0fak0=";
+
+    urls = [
+      "${mirror1}/GHS_psdef/bmwcra_1.tar.gz"
+      "${mirror2}/GHS_psdef/bmwcra_1.tar.gz"
+    ];
+  };
+
+  matrix-12 = fetchzip {
+    sha256 = "sha256-8OJqA/byhlAZd869TPUzZFdsOiwOoRGfKyhM+RMjXoY=";
+
+    urls = [
+      "${mirror1}/HB/nos1.tar.gz"
+      "${mirror2}/HB/nos1.tar.gz"
+    ];
+  };
+
+  matrix-13 = fetchzip {
+    sha256 = "sha256-FS0rKqmg+uHwsM/yGfQLBdd7LH/rUrdutkNGBD/Mh1I=";
+
+    urls = [
+      "${mirror1}/HB/nos2.tar.gz"
+      "${mirror2}/HB/nos2.tar.gz"
+    ];
+  };
+
+  matrix-14 = fetchzip {
+    sha256 = "sha256-DANnlrNJikrI7Pst9vRedtbuxepyHmCIu2yhltc4Qcs=";
+
+    urls = [
+      "${mirror1}/HB/nos3.tar.gz"
+      "${mirror2}/HB/nos3.tar.gz"
+    ];
+  };
+
+  matrix-15 = fetchzip {
+    sha256 = "sha256-21mUgqjWGUfYgiWwSrKh9vH8Vdt3xzcefmqYNYRpxiY=";
+
+    urls = [
+      "${mirror1}/HB/nos4.tar.gz"
+      "${mirror2}/HB/nos4.tar.gz"
+    ];
+  };
+
+  matrix-16 = fetchzip {
+    sha256 = "sha256-FOuXvGqBBFNkVS6cexmkluret54hCfCOdK+DOZllE4c=";
+
+    urls = [
+      "${mirror1}/HB/nos5.tar.gz"
+      "${mirror2}/HB/nos5.tar.gz"
+    ];
+  };
+
+  matrix-17 = fetchzip {
+    sha256 = "sha256-+7NI1rA/qQxYPpjXKHvAaCZ+LSaAJ4xuJvMRMBEUYxg=";
+
+    urls = [
+      "${mirror1}/HB/nos6.tar.gz"
+      "${mirror2}/HB/nos6.tar.gz"
+    ];
+  };
+
+  matrix-18 = fetchzip {
+    sha256 = "sha256-q3NxJjbwGGcFiQ9nhWfUKgZmdVwCfPmgQoqy0AqOsNc=";
+
+    urls = [
+      "${mirror1}/HB/nos7.tar.gz"
+      "${mirror2}/HB/nos7.tar.gz"
+    ];
+  };
+
+  matrix-19 = fetchzip {
+    sha256 = "sha256-0GAN6qmVfD+tprIigzuUUUwm5KVhkN9X65wMEvFltDY=";
+
+    urls = [
+      "${mirror1}/DNVS/shipsec1.tar.gz"
+      "${mirror2}/DNVS/shipsec1.tar.gz"
+    ];
+  };
+
+  matrix-20 = fetchzip {
+    sha256 = "sha256-f28Du/Urxsiq5NkRmRO10Zz9vvGRjEchquzHzbZpZ7U=";
+
+    urls = [
+      "${mirror1}/Cote/mplate.tar.gz"
+      "${mirror2}/Cote/mplate.tar.gz"
+    ];
+  };
+
+  matrix-21 = fetchzip {
+    sha256 = "sha256-O+Wy0NfCU1hVUOfNR1dJpvDHLBwwa301IRJDrQJnhak=";
+
+    urls = [
+      "${mirror1}/Bai/qc2534.tar.gz"
+      "${mirror2}/Bai/qc2534.tar.gz"
+    ];
+  };
+
+  matrix-22 = fetchzip {
+    sha256 = "sha256-oxMnt8U5Cf1ILWcBdU6W9jdSMMm+U6bIVl8nm3n3+OA=";
+
+    urls = [
+      "${mirror1}/Chevron/Chevron2.tar.gz"
+      "${mirror2}/Chevron/Chevron2.tar.gz"
+    ];
+  };
+
+  matrix-23 = fetchzip {
+    sha256 = "sha256-MFD9BxFI/3IS7yatW121BAI04fbqrXpgYDT5UKjeKcU=";
+
+    urls = [
+      "${mirror1}/Chevron/Chevron3.tar.gz"
+      "${mirror2}/Chevron/Chevron3.tar.gz"
+    ];
+  };
+
+  matrix-24 = fetchzip {
+    sha256 = "sha256-ikS8O51pe1nt3BNyhvfvqCbVL0+bg/da9bqGqeBDkTg=";
+
+    urls = [
+      "${mirror1}/Chevron/Chevron4.tar.gz"
+      "${mirror2}/Chevron/Chevron4.tar.gz"
+    ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/rocthrust/default.nix b/nixpkgs/pkgs/development/rocm-modules/5/rocthrust/default.nix
new file mode 100644
index 000000000000..b80b161f5799
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/rocthrust/default.nix
@@ -0,0 +1,87 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, rocmUpdateScript
+, cmake
+, rocm-cmake
+, rocprim
+, clr
+, gtest
+, buildTests ? false
+, buildBenchmarks ? false
+, gpuTargets ? [ ]
+}:
+
+stdenv.mkDerivation (finalAttrs: {
+  pname = "rocthrust";
+  version = "5.7.0";
+
+  outputs = [
+    "out"
+  ] ++ lib.optionals buildTests [
+    "test"
+  ] ++ lib.optionals buildBenchmarks [
+    "benchmark"
+  ];
+
+  src = fetchFromGitHub {
+    owner = "ROCmSoftwarePlatform";
+    repo = "rocThrust";
+    rev = "rocm-${finalAttrs.version}";
+    hash = "sha256-i0XCtJth8caVQT5oUgsxWXNzcePa02Gb7AQsthYTOv8=";
+  };
+
+  nativeBuildInputs = [
+    cmake
+    rocm-cmake
+    rocprim
+    clr
+  ];
+
+  buildInputs = lib.optionals buildTests [
+    gtest
+  ];
+
+  cmakeFlags = [
+    "-DCMAKE_CXX_COMPILER=hipcc"
+    "-DHIP_ROOT_DIR=${clr}"
+    # Manually define CMAKE_INSTALL_<DIR>
+    # See: https://github.com/NixOS/nixpkgs/pull/197838
+    "-DCMAKE_INSTALL_BINDIR=bin"
+    "-DCMAKE_INSTALL_LIBDIR=lib"
+    "-DCMAKE_INSTALL_INCLUDEDIR=include"
+  ] ++ lib.optionals (gpuTargets != [ ]) [
+    "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}"
+  ] ++ lib.optionals buildTests [
+    "-DBUILD_TEST=ON"
+  ] ++ lib.optionals buildBenchmarks [
+    "-DBUILD_BENCHMARKS=ON"
+  ] ++ lib.optionals (buildTests || buildBenchmarks) [
+    "-DCMAKE_CXX_FLAGS=-Wno-deprecated-builtins" # Too much spam
+  ];
+
+  postInstall = lib.optionalString buildTests ''
+    mkdir -p $test/bin
+    mv $out/bin/{test_*,*.hip} $test/bin
+  '' + lib.optionalString buildBenchmarks ''
+    mkdir -p $benchmark/bin
+    mv $out/bin/benchmark_* $benchmark/bin
+  '' + lib.optionalString (buildTests || buildBenchmarks) ''
+    rm -rf $out/bin
+  '';
+
+  passthru.updateScript = rocmUpdateScript {
+    name = finalAttrs.pname;
+    owner = finalAttrs.src.owner;
+    repo = finalAttrs.src.repo;
+  };
+
+  meta = with lib; {
+    description = "ROCm parallel algorithm library";
+    homepage = "https://github.com/ROCmSoftwarePlatform/rocThrust";
+    license = with licenses; [ asl20 ];
+    maintainers = teams.rocm.members;
+    platforms = platforms.linux;
+    broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
+  };
+})
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/roctracer/default.nix b/nixpkgs/pkgs/development/rocm-modules/5/roctracer/default.nix
new file mode 100644
index 000000000000..92e557426b10
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/roctracer/default.nix
@@ -0,0 +1,105 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, rocmUpdateScript
+, cmake
+, clang
+, clr
+, rocm-device-libs
+, rocprofiler
+, libxml2
+, doxygen
+, graphviz
+, gcc-unwrapped
+, rocm-runtime
+, python3Packages
+, buildDocs ? false # Nothing seems to be generated, so not making the output
+, buildTests ? false
+}:
+
+stdenv.mkDerivation (finalAttrs: {
+  pname = "roctracer";
+  version = "5.7.0";
+
+  outputs = [
+    "out"
+  ] ++ lib.optionals buildDocs [
+    "doc"
+  ] ++ lib.optionals buildTests [
+    "test"
+  ];
+
+  src = fetchFromGitHub {
+    owner = "ROCm-Developer-Tools";
+    repo = "roctracer";
+    rev = "rocm-${finalAttrs.version}";
+    hash = "sha256-P6QYyAjMRwFFWKF8AhbrYGe+mYVJXdbBW1or6vcobYU=";
+  };
+
+  nativeBuildInputs = [
+    cmake
+    clang
+    clr
+  ] ++ lib.optionals buildDocs [
+    doxygen
+    graphviz
+  ];
+
+  buildInputs = [
+    rocprofiler
+    libxml2
+    python3Packages.python
+    python3Packages.cppheaderparser
+  ];
+
+  cmakeFlags = [
+    "-DCMAKE_MODULE_PATH=${clr}/hip/cmake"
+    # Manually define CMAKE_INSTALL_<DIR>
+    # See: https://github.com/NixOS/nixpkgs/pull/197838
+    "-DCMAKE_INSTALL_BINDIR=bin"
+    "-DCMAKE_INSTALL_LIBDIR=lib"
+    "-DCMAKE_INSTALL_INCLUDEDIR=include"
+  ];
+
+  env.NIX_CFLAGS_COMPILE = toString [
+    # Needed with GCC 12
+    "-Wno-error=array-bounds"
+  ];
+
+  postPatch = ''
+    export HIP_DEVICE_LIB_PATH=${rocm-device-libs}/amdgcn/bitcode
+  '' + lib.optionalString (!buildTests) ''
+    substituteInPlace CMakeLists.txt \
+      --replace "add_subdirectory(test)" ""
+  '';
+
+  # Tests always fail, probably need GPU
+  # doCheck = buildTests;
+
+  postInstall = lib.optionalString buildDocs ''
+    mkdir -p $doc
+  '' + lib.optionalString buildTests ''
+    mkdir -p $test/bin
+    # Not sure why this is an install target
+    find $out/test -executable -type f -exec mv {} $test/bin \;
+    rm $test/bin/{*.sh,*.py}
+    patchelf --set-rpath $out/lib:${lib.makeLibraryPath (
+      finalAttrs.buildInputs ++ [ clr gcc-unwrapped.lib rocm-runtime ])} $test/bin/*
+    rm -rf $out/test
+  '';
+
+  passthru.updateScript = rocmUpdateScript {
+    name = finalAttrs.pname;
+    owner = finalAttrs.src.owner;
+    repo = finalAttrs.src.repo;
+  };
+
+  meta = with lib; {
+    description = "Tracer callback/activity library";
+    homepage = "https://github.com/ROCm-Developer-Tools/roctracer";
+    license = with licenses; [ mit ]; # mitx11
+    maintainers = teams.rocm.members;
+    platforms = platforms.linux;
+    broken = versions.minor finalAttrs.version != versions.minor clr.version;
+  };
+})
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/rocwmma/0000-dont-fetch-googletest.patch b/nixpkgs/pkgs/development/rocm-modules/5/rocwmma/0000-dont-fetch-googletest.patch
new file mode 100644
index 000000000000..fa47a3c42249
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/rocwmma/0000-dont-fetch-googletest.patch
@@ -0,0 +1,35 @@
+diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
+index 0d00883..86ce282 100644
+--- a/test/CMakeLists.txt
++++ b/test/CMakeLists.txt
+@@ -30,30 +30,6 @@ cmake_dependent_option( ROCWMMA_BUILD_VALIDATION_TESTS "Build validation tests"
+ cmake_dependent_option( ROCWMMA_BUILD_BENCHMARK_TESTS "Build benchmarking tests" OFF "ROCWMMA_BUILD_TESTS" OFF )
+ cmake_dependent_option( ROCWMMA_BUILD_EXTENDED_TESTS "Build extended test parameter coverage" OFF "ROCWMMA_BUILD_TESTS" OFF )
+ 
+-# Test/benchmark requires additional dependencies
+-include( FetchContent )
+-
+-FetchContent_Declare(
+-  googletest
+-  GIT_REPOSITORY https://github.com/google/googletest.git
+-  GIT_TAG release-1.12.1
+-)
+-FetchContent_GetProperties(googletest)
+-if(NOT googletest_POPULATED)
+-
+-  # Fetch the content using default details
+-  FetchContent_Populate(googletest)
+-  # Save the shared libs setting, then force to static libs
+-  set(BUILD_SHARED_LIBS_OLD ${BUILD_SHARED_LIBS})
+-  set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "Build SHARED libraries" FORCE)
+-  
+-  # Add gtest targets as static libs
+-  add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR})
+-  
+-  # Restore shared libs setting
+-  set(BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS_OLD} CACHE INTERNAL "Build SHARED libraries" FORCE)
+-endif()
+-
+ set(ROCWMMA_TEST_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR})
+ set(ROCWMMA_COMMON_TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/hip_device.cpp
+                                 ${CMAKE_CURRENT_SOURCE_DIR}/rocwmma_gtest_main.cpp)
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/rocwmma/default.nix b/nixpkgs/pkgs/development/rocm-modules/5/rocwmma/default.nix
new file mode 100644
index 000000000000..71d0e3fbe793
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/rocwmma/default.nix
@@ -0,0 +1,105 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, rocmUpdateScript
+, cmake
+, rocm-cmake
+, rocm-smi
+, clr
+, openmp
+, gtest
+, rocblas
+, buildTests ? false # Will likely fail building because wavefront shifts are not supported for certain archs
+, buildExtendedTests ? false
+, buildBenchmarks ? false
+, buildSamples ? false
+, gpuTargets ? [ ] # gpuTargets = [ "gfx908:xnack-" "gfx90a:xnack-" "gfx90a:xnack+" ... ]
+}:
+
+stdenv.mkDerivation (finalAttrs: {
+  pname = "rocwmma";
+  version = "5.7.0";
+
+  outputs = [
+    "out"
+  ] ++ lib.optionals (buildTests || buildBenchmarks) [
+    "test"
+  ] ++ lib.optionals buildBenchmarks [
+    "benchmark"
+  ] ++ lib.optionals buildSamples [
+    "sample"
+  ];
+
+  src = fetchFromGitHub {
+    owner = "ROCmSoftwarePlatform";
+    repo = "rocWMMA";
+    rev = "rocm-${finalAttrs.version}";
+    hash = "sha256-/EuBBSjhlMwJfsqYvRb9oCNC0hNkEa1JH1KUDLMSs08=";
+  };
+
+  patches = lib.optionals (buildTests || buildBenchmarks) [
+    ./0000-dont-fetch-googletest.patch
+  ];
+
+  nativeBuildInputs = [
+    cmake
+    rocm-cmake
+    clr
+  ];
+
+  buildInputs = [
+    openmp
+  ] ++ lib.optionals (buildTests || buildBenchmarks) [
+    rocm-smi
+    gtest
+    rocblas
+  ];
+
+  cmakeFlags = [
+    "-DCMAKE_CXX_COMPILER=hipcc"
+    "-DROCWMMA_BUILD_TESTS=${if buildTests || buildBenchmarks then "ON" else "OFF"}"
+    "-DROCWMMA_BUILD_SAMPLES=${if buildSamples then "ON" else "OFF"}"
+    # Manually define CMAKE_INSTALL_<DIR>
+    # See: https://github.com/NixOS/nixpkgs/pull/197838
+    "-DCMAKE_INSTALL_BINDIR=bin"
+    "-DCMAKE_INSTALL_LIBDIR=lib"
+    "-DCMAKE_INSTALL_INCLUDEDIR=include"
+  ] ++ lib.optionals (gpuTargets != [ ]) [
+    "-DGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}"
+  ] ++ lib.optionals buildExtendedTests [
+    "-DROCWMMA_BUILD_EXTENDED_TESTS=ON"
+  ] ++ lib.optionals buildBenchmarks [
+    "-DROCWMMA_BUILD_BENCHMARK_TESTS=ON"
+    "-DROCWMMA_BENCHMARK_WITH_ROCBLAS=ON"
+  ];
+
+  postInstall = lib.optionalString (buildTests || buildBenchmarks) ''
+    mkdir -p $test/bin
+    mv $out/bin/{*_test,*-validate} $test/bin
+  '' + lib.optionalString buildBenchmarks ''
+    mkdir -p $benchmark/bin
+    mv $out/bin/*-bench $benchmark/bin
+  '' + lib.optionalString buildSamples ''
+    mkdir -p $sample/bin
+    mv $out/bin/sgemmv $sample/bin
+    mv $out/bin/simple_gemm $sample/bin
+    mv $out/bin/simple_dlrm $sample/bin
+  '' + lib.optionalString (buildTests || buildBenchmarks || buildSamples) ''
+    rm -rf $out/bin
+  '';
+
+  passthru.updateScript = rocmUpdateScript {
+    name = finalAttrs.pname;
+    owner = finalAttrs.src.owner;
+    repo = finalAttrs.src.repo;
+  };
+
+  meta = with lib; {
+    description = "Mixed precision matrix multiplication and accumulation";
+    homepage = "https://github.com/ROCmSoftwarePlatform/rocWMMA";
+    license = with licenses; [ mit ];
+    maintainers = teams.rocm.members;
+    platforms = platforms.linux;
+    broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
+  };
+})
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/rpp/default.nix b/nixpkgs/pkgs/development/rocm-modules/5/rpp/default.nix
new file mode 100644
index 000000000000..eee10f2ab7c8
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/rpp/default.nix
@@ -0,0 +1,88 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, rocmUpdateScript
+, cmake
+, rocm-cmake
+, rocm-docs-core
+, half
+, clr
+, openmp
+, boost
+, python3Packages
+, buildDocs ? false # Needs internet
+, useOpenCL ? false
+, useCPU ? false
+, gpuTargets ? [ ]
+}:
+
+stdenv.mkDerivation (finalAttrs: {
+  pname = "rpp-" + (
+    if (!useOpenCL && !useCPU) then "hip"
+    else if (!useOpenCL && !useCPU) then "opencl"
+    else "cpu"
+  );
+
+  version = "5.7.0";
+
+  src = fetchFromGitHub {
+    owner = "GPUOpen-ProfessionalCompute-Libraries";
+    repo = "rpp";
+    rev = "rocm-${finalAttrs.version}";
+    hash = "sha256-s6ODmxPBLpR5f8VALaW6F0p0rZSxSd2LH2+60SEfLCk=";
+  };
+
+  nativeBuildInputs = [
+    cmake
+    rocm-cmake
+    clr
+  ] ++ lib.optionals buildDocs [
+    rocm-docs-core
+    python3Packages.python
+  ];
+
+  buildInputs = [
+    half
+    openmp
+    boost
+  ];
+
+  cmakeFlags = [
+    "-DROCM_PATH=${clr}"
+  ] ++ lib.optionals (gpuTargets != [ ]) [
+    "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}"
+  ] ++ lib.optionals (!useOpenCL && !useCPU) [
+    "-DCMAKE_C_COMPILER=hipcc"
+    "-DCMAKE_CXX_COMPILER=hipcc"
+    "-DBACKEND=HIP"
+  ] ++ lib.optionals (useOpenCL && !useCPU) [
+    "-DBACKEND=OCL"
+  ] ++ lib.optionals useCPU [
+    "-DBACKEND=CPU"
+  ];
+
+  postPatch = lib.optionalString (!useOpenCL && !useCPU) ''
+    # Bad path
+    substituteInPlace CMakeLists.txt \
+      --replace "COMPILER_FOR_HIP \''${ROCM_PATH}/llvm/bin/clang++" "COMPILER_FOR_HIP ${clr}/bin/hipcc"
+  '';
+
+  postBuild = lib.optionalString buildDocs ''
+    python3 -m sphinx -T -E -b html -d _build/doctrees -D language=en ../docs _build/html
+  '';
+
+  passthru.updateScript = rocmUpdateScript {
+    name = finalAttrs.pname;
+    owner = finalAttrs.src.owner;
+    repo = finalAttrs.src.repo;
+  };
+
+  meta = with lib; {
+    description = "Comprehensive high-performance computer vision library for AMD processors";
+    homepage = "https://github.com/GPUOpen-ProfessionalCompute-Libraries/rpp";
+    license = with licenses; [ mit ];
+    maintainers = teams.rocm.members;
+    platforms = platforms.linux;
+    broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
+  };
+})
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/tensile/default.nix b/nixpkgs/pkgs/development/rocm-modules/5/tensile/default.nix
new file mode 100644
index 000000000000..86dbaa95e192
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/tensile/default.nix
@@ -0,0 +1,65 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, rocmUpdateScript
+, buildPythonPackage
+, pytestCheckHook
+, setuptools
+, pyyaml
+, msgpack
+, pandas
+, joblib
+, filelock
+, rocminfo
+}:
+
+buildPythonPackage rec {
+  pname = "tensile";
+  version = "5.7.0";
+  format = "pyproject";
+
+  src = fetchFromGitHub {
+    owner = "ROCmSoftwarePlatform";
+    repo = "Tensile";
+    rev = "rocm-${version}";
+    hash = "sha256-CyPGiM/53duJc/oNtOsl6JSsl9uOOYm5R7O6YXaVOm4=";
+  };
+
+  buildInputs = [ setuptools ];
+
+  propagatedBuildInputs = [
+    pyyaml
+    msgpack
+    pandas
+    joblib
+  ];
+
+  doCheck = false; # Too many errors, not sure how to set this up properly
+
+  nativeCheckInputs = [
+    pytestCheckHook
+    filelock
+    rocminfo
+  ];
+
+  preCheck = ''
+    export ROCM_PATH=${rocminfo}
+  '';
+
+  pythonImportsCheck = [ "Tensile" ];
+
+  passthru.updateScript = rocmUpdateScript {
+    name = pname;
+    owner = src.owner;
+    repo = src.repo;
+  };
+
+  meta = with lib; {
+    description = "GEMMs and tensor contractions";
+    homepage = "https://github.com/ROCmSoftwarePlatform/Tensile";
+    license = with licenses; [ mit ];
+    maintainers = teams.rocm.members;
+    platforms = platforms.linux;
+    broken = versions.minor version != versions.minor stdenv.cc.version;
+  };
+}
diff --git a/nixpkgs/pkgs/development/rocm-modules/5/update.nix b/nixpkgs/pkgs/development/rocm-modules/5/update.nix
new file mode 100644
index 000000000000..1cc7e354d240
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/5/update.nix
@@ -0,0 +1,32 @@
+{ lib
+, writeScript
+}:
+
+{ name ? ""
+, owner ? ""
+, repo ? ""
+, page ? "releases?per_page=1"
+, filter ? ".[0].tag_name | split(\"-\") | .[1]"
+}:
+
+let
+  pname =
+    if lib.hasPrefix "rocm-llvm-" name
+    then "llvm.${lib.removePrefix "rocm-llvm-" name}"
+    else name;
+
+  updateScript = writeScript "update.sh" ''
+    #!/usr/bin/env nix-shell
+    #!nix-shell -i bash -p curl jq common-updater-scripts
+    version="$(curl ''${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} \
+      -sL "https://api.github.com/repos/${owner}/${repo}/${page}" | jq '${filter}' --raw-output)"
+
+    IFS='.' read -a version_arr <<< "$version"
+
+    if [ "''${#version_arr[*]}" == 2 ]; then
+      version="''${version}.0"
+    fi
+
+    update-source-version rocmPackages_5.${pname} "$version" --ignore-same-hash
+  '';
+in [ updateScript ]