ocamlPackages.hxd: 0.3.2 -> 0.3.3 (#364231)
[NixPkgs.git] / nixos / modules / services / hardware / auto-epp.nix
blob88f49106a258c7871e5823e966c5bde8d470268d
2   config,
3   lib,
4   pkgs,
5   ...
6 }:
8 let
9   cfg = config.services.auto-epp;
10   format = pkgs.formats.ini { };
12   inherit (lib) mkOption types;
15   options = {
16     services.auto-epp = {
17       enable = lib.mkEnableOption "auto-epp for amd active pstate";
19       package = lib.mkPackageOption pkgs "auto-epp" { };
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
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               };
39               epp_state_for_BAT = mkOption {
40                 type = types.str;
41                 default = "power";
42                 description = ''
43                   `energy_performance_preference` when on battery
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   };
63   config = lib.mkIf cfg.enable {
65     boot.kernelParams = [
66       "amd_pstate=active"
67     ];
69     environment.etc."auto-epp.conf".source = format.generate "auto-epp.conf" cfg.settings;
70     systemd.packages = [ cfg.package ];
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   };
85   meta.maintainers = with lib.maintainers; [ lamarios ];