at 24.11-pre 2.3 kB view raw
1{ config, lib, pkgs, ... }: 2 3let 4 cfg = config.services.auto-epp; 5 format = pkgs.formats.ini {}; 6 7 inherit (lib) mkOption types; 8in { 9 options = { 10 services.auto-epp = { 11 enable = lib.mkEnableOption "auto-epp for amd active pstate"; 12 13 package = lib.mkPackageOptionMD pkgs "auto-epp" {}; 14 15 settings = mkOption { 16 type = types.submodule { 17 freeformType = format.type; 18 options = { 19 Settings = { 20 epp_state_for_AC = mkOption { 21 type = types.str; 22 default = "balance_performance"; 23 description = '' 24 energy_performance_preference when on plugged in 25 26 ::: {.note} 27 See available epp states by running: 28 {command}`cat /sys/devices/system/cpu/cpu0/cpufreq/energy_performance_available_preferences` 29 ::: 30 ''; 31 }; 32 33 epp_state_for_BAT = mkOption { 34 type = types.str; 35 default = "power"; 36 description = '' 37 `energy_performance_preference` when on battery 38 39 ::: {.note} 40 See available epp states by running: 41 {command}`cat /sys/devices/system/cpu/cpu0/cpufreq/energy_performance_available_preferences` 42 ::: 43 ''; 44 }; 45 }; 46 }; 47 }; 48 default = {}; 49 description = '' 50 Settings for the auto-epp application. 51 See upstream example: <https://github.com/jothi-prasath/auto-epp/blob/master/sample-auto-epp.conf> 52 ''; 53 }; 54 }; 55 }; 56 57 config = lib.mkIf cfg.enable { 58 59 boot.kernelParams = [ 60 "amd_pstate=active" 61 ]; 62 63 environment.etc."auto-epp.conf".source = format.generate "auto-epp.conf" cfg.settings; 64 systemd.packages = [ cfg.package ]; 65 66 systemd.services.auto-epp = { 67 after = [ "multi-user.target" ]; 68 wantedBy = [ "multi-user.target" ]; 69 description = "auto-epp - Automatic EPP Changer for amd-pstate-epp"; 70 serviceConfig = { 71 Type = "simple"; 72 User = "root"; 73 ExecStart = lib.getExe cfg.package; 74 Restart = "on-failure"; 75 }; 76 }; 77 }; 78 79 meta.maintainers = with lib.maintainers; [ lamarios ]; 80}