vuls: init at 0.27.0
[NixPkgs.git] / nixos / modules / services / hardware / auto-epp.nix
blob1d939a98142e0ae9dda83d6d2e2d37326afdd47a
1 { config, lib, pkgs, ... }:
3 let
4   cfg = config.services.auto-epp;
5   format = pkgs.formats.ini {};
7   inherit (lib) mkOption types;
8 in {
9   options = {
10     services.auto-epp = {
11       enable = lib.mkEnableOption "auto-epp for amd active pstate";
13       package = lib.mkPackageOption pkgs "auto-epp" {};
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
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               };
33               epp_state_for_BAT = mkOption {
34                 type = types.str;
35                 default = "power";
36                 description = ''
37                   `energy_performance_preference` when on battery
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   };
57   config = lib.mkIf cfg.enable {
59     boot.kernelParams = [
60       "amd_pstate=active"
61     ];
63     environment.etc."auto-epp.conf".source = format.generate "auto-epp.conf" cfg.settings;
64     systemd.packages = [ cfg.package ];
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   };
79   meta.maintainers = with lib.maintainers; [ lamarios ];