Merge pull request #261378 from lamarios/auto-epp

auto-epp: init at 1.2.1
This commit is contained in:
Peder Bergebakken Sundt 2023-11-30 19:47:12 +01:00 committed by GitHub
commit 23fb8f614b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 116 additions and 0 deletions

View file

@ -10010,6 +10010,12 @@
githubId = 55911173;
name = "Gwendolyn Quasebarth";
};
lamarios = {
matrix = "@lamarios:matrix.org";
github = "lamarios";
githubId = 1192563;
name = "Paul Fauchon";
};
lambda-11235 = {
email = "taranlynn0@gmail.com";
github = "lambda-11235";

View file

@ -516,6 +516,7 @@
./services/hardware/argonone.nix
./services/hardware/asusd.nix
./services/hardware/auto-cpufreq.nix
./services/hardware/auto-epp.nix
./services/hardware/bluetooth.nix
./services/hardware/bolt.nix
./services/hardware/brltty.nix

View file

@ -0,0 +1,80 @@
{ config, lib, pkgs, ... }:
let
cfg = config.services.auto-epp;
format = pkgs.formats.ini {};
inherit (lib) mkOption types;
in {
options = {
services.auto-epp = {
enable = lib.mkEnableOption (lib.mdDoc "auto-epp for amd active pstate");
package = lib.mkPackageOptionMD pkgs "auto-epp" {};
settings = mkOption {
type = types.submodule {
freeformType = format.type;
options = {
Settings = {
epp_state_for_AC = mkOption {
type = types.str;
default = "balance_performance";
description = lib.mdDoc ''
energy_performance_preference when on plugged in
::: {.note}
See available epp states by running:
{command}`cat /sys/devices/system/cpu/cpu0/cpufreq/energy_performance_available_preferences`
:::
'';
};
epp_state_for_BAT = mkOption {
type = types.str;
default = "power";
description = lib.mdDoc ''
`energy_performance_preference` when on battery
::: {.note}
See available epp states by running:
{command}`cat /sys/devices/system/cpu/cpu0/cpufreq/energy_performance_available_preferences`
:::
'';
};
};
};
};
default = {};
description = lib.mdDoc ''
Settings for the auto-epp application.
See upstream example: <https://github.com/jothi-prasath/auto-epp/blob/master/sample-auto-epp.conf>
'';
};
};
};
config = lib.mkIf cfg.enable {
boot.kernelParams = [
"amd_pstate=active"
];
environment.etc."auto-epp.conf".source = format.generate "auto-epp.conf" cfg.settings;
systemd.packages = [ cfg.package ];
systemd.services.auto-epp = {
after = [ "multi-user.target" ];
wantedBy = [ "multi-user.target" ];
description = "auto-epp - Automatic EPP Changer for amd-pstate-epp";
serviceConfig = {
Type = "simple";
User = "root";
ExecStart = lib.getExe cfg.package;
Restart = "on-failure";
};
};
};
meta.maintainers = with lib.maintainers; [ lamarios ];
}

View file

@ -0,0 +1,29 @@
{ lib, stdenv, fetchFromGitHub, python3 }:
stdenv.mkDerivation rec {
pname = "auto-epp";
version = "1.2.1";
src = fetchFromGitHub {
owner = "jothi-prasath";
repo = "auto-epp";
rev = "refs/tags/v${version}";
hash = "sha256-7sI8K+7ZAdzBN/XOzYQQZ1f9t+fFo6fcXYzX6abNyQ8=";
};
buildInputs = [ python3 ];
installPhase = ''
runHook preInstall
install -Dm555 auto-epp $out/bin/auto-epp
runHook postInstall
'';
meta = with lib; {
mainProgram = "auto-epp";
homepage = "https://github.com/jothi-prasath/auto-epp";
description = "Auto-epp (energy performance preference) for AMD processors when amd_pstate=active";
platforms = platforms.linux;
license = licenses.mit;
maintainers = [ maintainers.lamarios ];
};
}