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