2021-02-13 14:23:35 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.services.auto-cpufreq;
|
2023-04-12 12:48:02 +00:00
|
|
|
cfgFilename = "auto-cpufreq.conf";
|
|
|
|
cfgFile = format.generate cfgFilename cfg.settings;
|
|
|
|
|
|
|
|
format = pkgs.formats.ini {};
|
2021-02-13 14:23:35 +00:00
|
|
|
in {
|
|
|
|
options = {
|
|
|
|
services.auto-cpufreq = {
|
2022-09-09 14:08:57 +00:00
|
|
|
enable = mkEnableOption (lib.mdDoc "auto-cpufreq daemon");
|
2023-04-12 12:48:02 +00:00
|
|
|
|
|
|
|
settings = mkOption {
|
|
|
|
description = lib.mdDoc ''
|
|
|
|
Configuration for `auto-cpufreq`.
|
|
|
|
|
|
|
|
See its [example configuration file] for supported settings.
|
|
|
|
[example configuration file]: https://github.com/AdnanHodzic/auto-cpufreq/blob/master/auto-cpufreq.conf-example
|
|
|
|
'';
|
|
|
|
|
|
|
|
default = {};
|
|
|
|
type = types.submodule { freeformType = format.type; };
|
|
|
|
};
|
2021-02-13 14:23:35 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
environment.systemPackages = [ pkgs.auto-cpufreq ];
|
|
|
|
|
2021-06-28 23:13:55 +00:00
|
|
|
systemd = {
|
|
|
|
packages = [ pkgs.auto-cpufreq ];
|
|
|
|
services.auto-cpufreq = {
|
|
|
|
# Workaround for https://github.com/NixOS/nixpkgs/issues/81138
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
path = with pkgs; [ bash coreutils ];
|
2023-04-12 12:48:02 +00:00
|
|
|
|
|
|
|
serviceConfig.ExecStart = [
|
|
|
|
""
|
2023-04-29 16:46:19 +00:00
|
|
|
"${lib.getExe pkgs.auto-cpufreq} --daemon --config ${cfgFile}"
|
2023-04-12 12:48:02 +00:00
|
|
|
];
|
2021-06-28 23:13:55 +00:00
|
|
|
};
|
|
|
|
};
|
2021-02-13 14:23:35 +00:00
|
|
|
};
|
|
|
|
}
|