diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix index 05eba26df6f2..adc0d3563ea4 100644 --- a/maintainers/maintainer-list.nix +++ b/maintainers/maintainer-list.nix @@ -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"; diff --git a/nixos/doc/manual/release-notes/rl-2405.section.md b/nixos/doc/manual/release-notes/rl-2405.section.md index a8cefa0da604..2d487bd23e1b 100644 --- a/nixos/doc/manual/release-notes/rl-2405.section.md +++ b/nixos/doc/manual/release-notes/rl-2405.section.md @@ -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). diff --git a/nixos/modules/hardware/cpu/amd-ryzen-smu.nix b/nixos/modules/hardware/cpu/amd-ryzen-smu.nix new file mode 100644 index 000000000000..b1a5895aaa24 --- /dev/null +++ b/nixos/modules/hardware/cpu/amd-ryzen-smu.nix @@ -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 ]; +} diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 9fc036f9213a..32ce0f3ec58d 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -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 @@ -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 diff --git a/nixos/modules/programs/ryzen-monitor-ng.nix b/nixos/modules/programs/ryzen-monitor-ng.nix new file mode 100644 index 000000000000..cb0c391ce6b1 --- /dev/null +++ b/nixos/modules/programs/ryzen-monitor-ng.nix @@ -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 ]; +} diff --git a/pkgs/by-name/ry/ryzen-monitor-ng/package.nix b/pkgs/by-name/ry/ryzen-monitor-ng/package.nix new file mode 100644 index 000000000000..9a9996ecf61a --- /dev/null +++ b/pkgs/by-name/ry/ryzen-monitor-ng/package.nix @@ -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"; + }; +} 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 000000000000..7f899f2c2c90 --- /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"; + }; +} diff --git a/pkgs/top-level/linux-kernels.nix b/pkgs/top-level/linux-kernels.nix index 21b044583b9e..4ab227d9975a 100644 --- a/pkgs/top-level/linux-kernels.nix +++ b/pkgs/top-level/linux-kernels.nix @@ -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 {