From 470a70148a22406aeb248405858ff4fc6f39dbce Mon Sep 17 00:00:00 2001 From: coolneng Date: Tue, 9 Jan 2024 13:55:49 +0100 Subject: [PATCH] Couple power-profiles-daemon and AMD P-State EPP --- flake.lock | 23 ++++++++++++++++++++++- flake.nix | 16 ++++++++++------ modules/power.nix | 3 +++ 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/flake.lock b/flake.lock index 78bbf8b..042d0d1 100644 --- a/flake.lock +++ b/flake.lock @@ -397,6 +397,26 @@ "type": "github" } }, + "pp-to-amd-epp": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1700307756, + "narHash": "sha256-PlinfzkBIWJMO9y2kb1b/1CArG6pMJZ6wyolNMdKSJM=", + "owner": "marcinx64", + "repo": "pp-to-amd-epp", + "rev": "0fbac782cd32313864b4e5a0ff975673d6ceda6e", + "type": "github" + }, + "original": { + "owner": "marcinx64", + "repo": "pp-to-amd-epp", + "type": "github" + } + }, "pre-commit-hooks-nix": { "inputs": { "flake-compat": [ @@ -437,7 +457,8 @@ "nix-index-database": "nix-index-database", "nixos-hardware": "nixos-hardware", "nixpkgs": "nixpkgs", - "openconnect-sso": "openconnect-sso" + "openconnect-sso": "openconnect-sso", + "pp-to-amd-epp": "pp-to-amd-epp" } }, "rust-overlay": { diff --git a/flake.nix b/flake.nix index 4d52fd6..fd95b6e 100644 --- a/flake.nix +++ b/flake.nix @@ -32,14 +32,17 @@ url = "github:nix-community/lanzaboote/v0.3.0"; inputs.nixpkgs.follows = "nixpkgs"; }; + pp-to-amd-epp = { + url = "github:marcinx64/pp-to-amd-epp"; + inputs.nixpkgs.follows = "nixpkgs"; + }; local-bitwig = { url = "path:/home/coolneng/Projects/panacea/assets/bitwig"; flake = false; }; }; - outputs = { self, nixpkgs, nixos-hardware, agenix, nix-index-database - , lanzaboote, ... }@inputs: + outputs = { self, nixpkgs, ... }@inputs: let system = "x86_64-linux"; @@ -62,10 +65,11 @@ inherit system; modules = [ (import ./configuration.nix) - nixos-hardware.nixosModules.lenovo-thinkpad-e14-amd - agenix.nixosModules.age - nix-index-database.nixosModules.nix-index - lanzaboote.nixosModules.lanzaboote + inputs.nixos-hardware.nixosModules.lenovo-thinkpad-e14-amd + inputs.agenix.nixosModules.age + inputs.nix-index-database.nixosModules.nix-index + inputs.lanzaboote.nixosModules.lanzaboote + inputs.pp-to-amd-epp.nixosModules.pp-to-amd-epp ]; specialArgs = { inherit inputs; diff --git a/modules/power.nix b/modules/power.nix index c8326b7..b0c1fe9 100644 --- a/modules/power.nix +++ b/modules/power.nix @@ -4,6 +4,9 @@ # Enable power-profiles-daemon services.power-profiles-daemon.enable = true; + # Integration of AMD P-State EPP with power-profiles-daemon + services.pp-to-amd-epp.enable = true; + # Suspend when the battery is critical and autosuspend USB and PCI services.udev.extraRules = '' SUBSYSTEM=="power_supply", ATTR{status}=="Discharging", ATTR{model_name}=="01AV405", ATTR{capacity}=="[0-5]", RUN+="${config.systemd.package}/bin/systemctl suspend -i"