Skip to content

Commit

Permalink
Merge pull request #271342 from PhDyellow/ryzen_smu
Browse files Browse the repository at this point in the history
ryzen_smu: init at 0.1.5, ryzen_monitor_ng: init at 2.0.5
  • Loading branch information
Aleksanaa committed Apr 11, 2024
2 parents 03b8fd0 + 97899b5 commit 029c95c
Show file tree
Hide file tree
Showing 8 changed files with 185 additions and 0 deletions.
6 changes: 6 additions & 0 deletions maintainers/maintainer-list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15508,6 +15508,12 @@
fingerprint = "7756 E88F 3C6A 47A5 C5F0 CDFB AB54 6777 F93E 20BF";
}];
};
phdyellow = {
name = "Phil Dyer";
email = "phildyer@protonmail.com";
github = "PhDyellow";
githubId = 7740661;
};
phfroidmont = {
name = "Paul-Henri Froidmont";
email = "nix.contact-j9dw4d@froidmont.org";
Expand Down
4 changes: 4 additions & 0 deletions nixos/doc/manual/release-notes/rl-2405.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ Use `services.pipewire.extraConfig` or `services.pipewire.configPackages` for Pi

- [maubot](https://github.com/maubot/maubot), a plugin-based Matrix bot framework. Available as [services.maubot](#opt-services.maubot.enable).

- [ryzen-monitor-ng](https://github.com/mann1x/ryzen_monitor_ng), a desktop AMD CPU power monitor and controller, similar to Ryzen Master but for Linux. Available as [programs.ryzen-monitor-ng](#opt-programs.ryzen-monitor-ng.enable)

- [ryzen-smu](https://gitlab.com/leogx9r/ryzen_smu), Linux kernel driver to expose the SMU (System Management Unit) for certain AMD Ryzen Processors. Includes the userspace program `monitor_cpu`. Available at [hardward.cpu.amd.ryzen-smu](#opt-hardware.cpu.amd.ryzen-smu.enable)

- systemd's gateway, upload, and remote services, which provides ways of sending journals across the network. Enable using [services.journald.gateway](#opt-services.journald.gateway.enable), [services.journald.upload](#opt-services.journald.upload.enable), and [services.journald.remote](#opt-services.journald.remote.enable).

- [GNS3](https://www.gns3.com/), a network software emulator. Available as [services.gns3-server](#opt-services.gns3-server.enable).
Expand Down
26 changes: 26 additions & 0 deletions nixos/modules/hardware/cpu/amd-ryzen-smu.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{ config
, lib
, ...
}:
let
inherit (lib) mkEnableOption mkIf;
cfg = config.hardware.cpu.amd.ryzen-smu;
ryzen-smu = config.boot.kernelPackages.ryzen-smu;
in
{
options.hardware.cpu.amd.ryzen-smu = {
enable = mkEnableOption ''
ryzen_smu, a linux kernel driver that exposes access to the SMU (System Management Unit) for certain AMD Ryzen Processors.
WARNING: Damage cause by use of your AMD processor outside of official AMD specifications or outside of factory settings are not covered under any AMD product warranty and may not be covered by your board or system manufacturer's warranty
'';
};

config = mkIf cfg.enable {
boot.kernelModules = [ "ryzen-smu" ];
boot.extraModulePackages = [ ryzen-smu ];
environment.systemPackages = [ ryzen-smu ];
};

meta.maintainers = with lib.maintainers; [ Cryolitia phdyellow ];
}
2 changes: 2 additions & 0 deletions nixos/modules/module-list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
./hardware/corectrl.nix
./hardware/cpu/amd-microcode.nix
./hardware/cpu/amd-sev.nix
./hardware/cpu/amd-ryzen-smu.nix
./hardware/cpu/intel-microcode.nix
./hardware/cpu/intel-sgx.nix
./hardware/cpu/x86-msr.nix
Expand Down Expand Up @@ -251,6 +252,7 @@
./programs/regreet.nix
./programs/rog-control-center.nix
./programs/rust-motd.nix
./programs/ryzen-monitor-ng.nix
./programs/screen.nix
./programs/seahorse.nix
./programs/sedutil.nix
Expand Down
35 changes: 35 additions & 0 deletions nixos/modules/programs/ryzen-monitor-ng.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{ pkgs
, config
, lib
, ...
}:
let
inherit (lib) mkEnableOption mkPackageOption mkIf;
cfg = config.programs.ryzen-monitor-ng;
in
{
options = {
programs.ryzen-monitor-ng = {
enable = mkEnableOption ''
ryzen_monitor_ng, a userspace application for setting and getting Ryzen SMU (System Management Unit) parameters via the ryzen_smu kernel driver.
Monitor power information of Ryzen processors via the PM table of the SMU.
SMU Set and Get for many parameters and CO counts.
https://github.com/mann1x/ryzen_monitor_ng
WARNING: Damage cause by use of your AMD processor outside of official AMD specifications or outside of factory settings are not covered under any AMD product warranty and may not be covered by your board or system manufacturer's warranty
'';

package = mkPackageOption pkgs "ryzen-monitor-ng" {};
};
};

config = mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
hardware.cpu.amd.ryzen-smu.enable = true;
};

meta.maintainers = with lib.maintainers; [ Cryolitia phdyellow ];
}
41 changes: 41 additions & 0 deletions pkgs/by-name/ry/ryzen-monitor-ng/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{ lib, stdenv, fetchFromGitHub }:

stdenv.mkDerivation {
pname = "ryzen-monitor-ng";
version = "2.0.5-unstable-2023-11-05";

# Upstream has not updated ryzen_smu header version
# This fork corrects ryzen_smu header version and
# adds support for Matisse AMD CPUs.
src = fetchFromGitHub {
owner = "plasmin";
repo = "ryzen_monitor_ng";
rev = "8b7854791d78de731a45ce7d30dd17983228b7b1";
hash = "sha256-fcW2fEsCFliRnMFnboR0jchzVIlCYbr2AE6AS06cb6o=";
};

## Remove binaries committed into upstream repo
preBuild = ''
rm src/ryzen_monitor
'';

makeTargets = [ "clean" "install" ];

installPhase = ''
runHook preInstall
mkdir -p $out/bin
mv ./src/ryzen_monitor $out/bin
runHook postInstall
'';

meta = with lib; {
description = "Access Ryzen SMU information exposed by the ryzen_smu driver";
homepage = "https://github.com/mann1x/ryzen_monitor_ng";
license = licenses.agpl3Only;
platforms = [ "x86_64-linux" ];
maintainers = with maintainers; [ phdyellow ];
mainProgram = "ryzen_monitor";
};
}
69 changes: 69 additions & 0 deletions pkgs/os-specific/linux/ryzen-smu/default.nix
Original file line number Diff line number Diff line change
@@ -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";
};
}
2 changes: 2 additions & 0 deletions pkgs/top-level/linux-kernels.nix
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,8 @@ in {

ithc = callPackage ../os-specific/linux/ithc { };

ryzen-smu = callPackage ../os-specific/linux/ryzen-smu { };

zenpower = callPackage ../os-specific/linux/zenpower { };

zfs_2_1 = callPackage ../os-specific/linux/zfs/2_1.nix {
Expand Down

0 comments on commit 029c95c

Please sign in to comment.