about summary refs log tree commit diff
path: root/pkgs/os-specific
diff options
context:
space:
mode:
authorPhil Dyer <phildyer@protonmail.com>2024-04-11 11:39:09 +1000
committerPhil Dyer <phildyer@protonmail.com>2024-04-11 11:39:09 +1000
commitcc0f05649269e39170b59716af72ff738ef5b931 (patch)
treec19156af664dbb623f9d7873c39f52574f77b5df /pkgs/os-specific
parent9cd5f606b09aaae3222f79ded3aea59b9f0532bd (diff)
ryzen-smu: init at 0.1.5
A Linux kernel driver that exposes access to the
SMU (System Management Unit) for certain AMD Ryzen Processors.

Contains monitor_cpu, a userspace tool for viewing info.

Using fork of original to match ryzen_monitor_ng, a more advanced
userspace tool for accessing the SMU via this kernel module,
planned for a later commit.
Diffstat (limited to 'pkgs/os-specific')
-rw-r--r--pkgs/os-specific/linux/ryzen-smu/default.nix69
1 files changed, 69 insertions, 0 deletions
diff --git a/pkgs/os-specific/linux/ryzen-smu/default.nix b/pkgs/os-specific/linux/ryzen-smu/default.nix
new file mode 100644
index 0000000000000..7f899f2c2c90c
--- /dev/null
+++ b/pkgs/os-specific/linux/ryzen-smu/default.nix
@@ -0,0 +1,69 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, kernel
+}:
+
+let
+  version = "0.1.5-unstable-2024-01-03";
+
+  ## Upstream has not been merging PRs.
+  ## Nixpkgs maintainers are providing a
+  ## repo with PRs merged until upstream is
+  ## updated.
+  src = fetchFromGitHub {
+    owner = "Cryolitia";
+    repo = "ryzen_smu";
+    rev = "ce1aa918efa33ca79998f0f7d467c04d4b07016c";
+    hash = "sha256-s9SSmbL6ixWqZUKEhrZdxN4xoWgk+8ClZPoKq2FDAAE=";
+  };
+
+  monitor-cpu = stdenv.mkDerivation {
+    pname = "monitor-cpu";
+    inherit version src;
+
+    makeFlags = [
+      "-C userspace"
+    ];
+
+    installPhase = ''
+    runHook preInstall
+
+    install userspace/monitor_cpu -Dm755 -t $out/bin
+
+    runHook postInstall
+  '';
+  };
+
+in
+stdenv.mkDerivation {
+  pname = "ryzen-smu-${kernel.version}";
+  inherit version src;
+
+  hardeningDisable = [ "pic" ];
+
+  nativeBuildInputs = kernel.moduleBuildDependencies;
+
+  makeFlags = [
+    "TARGET=${kernel.modDirVersion}"
+    "KERNEL_BUILD=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
+  ];
+
+  installPhase = ''
+    runHook preInstall
+
+    install ryzen_smu.ko -Dm444 -t $out/lib/modules/${kernel.modDirVersion}/kernel/drivers/ryzen_smu
+    install ${monitor-cpu}/bin/monitor_cpu -Dm755 -t $out/bin
+
+    runHook postInstall
+  '';
+
+  meta = with lib; {
+    description = "A Linux kernel driver that exposes access to the SMU (System Management Unit) for certain AMD Ryzen Processors";
+    homepage = "https://gitlab.com/leogx9r/ryzen_smu";
+    license = licenses.gpl2Plus;
+    maintainers = with maintainers; [ Cryolitia phdyellow ];
+    platforms = [ "x86_64-linux" ];
+    mainProgram = "monitor_cpu";
+  };
+}