2021-01-08 15:57:48 -05:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
let
|
|
|
|
cfg = config.services.auto-cpufreq;
|
2023-03-28 19:09:54 +00:00
|
|
|
cfgFilename = "auto-cpufreq.conf";
|
|
|
|
cfgFile = format.generate cfgFilename cfg.settings;
|
|
|
|
|
|
|
|
format = pkgs.formats.ini { };
|
2021-01-08 15:57:48 -05:00
|
|
|
in
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
services.auto-cpufreq = {
|
2024-08-27 20:43:14 +02:00
|
|
|
enable = lib.mkEnableOption "auto-cpufreq daemon";
|
2023-03-28 19:09:54 +00:00
|
|
|
|
2024-08-27 20:43:14 +02:00
|
|
|
settings = lib.mkOption {
|
2023-03-28 19:09:54 +00:00
|
|
|
description = ''
|
|
|
|
Configuration for `auto-cpufreq`.
|
|
|
|
|
2023-09-06 23:41:24 +02:00
|
|
|
The available options can be found in [the example configuration file](https://github.com/AdnanHodzic/auto-cpufreq/blob/v${pkgs.auto-cpufreq.version}/auto-cpufreq.conf-example).
|
2023-03-28 19:09:54 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
default = { };
|
2024-08-27 20:43:14 +02:00
|
|
|
type = lib.types.submodule { freeformType = format.type; };
|
2023-03-28 19:09:54 +00:00
|
|
|
};
|
2021-01-08 15:57:48 -05:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-08-27 20:43:14 +02:00
|
|
|
config = lib.mkIf cfg.enable {
|
2021-01-08 15:57:48 -05:00
|
|
|
environment.systemPackages = [ pkgs.auto-cpufreq ];
|
|
|
|
|
2021-06-14 19:53:47 -04: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-09 19:15:49 +00:00
|
|
|
|
2023-09-06 23:41:24 +02:00
|
|
|
serviceConfig.WorkingDirectory = "";
|
2023-04-09 19:15:49 +00:00
|
|
|
serviceConfig.ExecStart = [
|
|
|
|
""
|
2023-04-28 14:22:39 +03:00
|
|
|
"${lib.getExe pkgs.auto-cpufreq} --daemon --config ${cfgFile}"
|
2023-04-09 19:15:49 +00:00
|
|
|
];
|
2021-06-14 19:53:47 -04:00
|
|
|
};
|
|
|
|
};
|
2021-01-08 15:57:48 -05:00
|
|
|
};
|
2023-09-06 23:41:24 +02:00
|
|
|
|
|
|
|
# uses attributes of the linked package
|
2023-09-13 10:25:53 +00:00
|
|
|
meta = {
|
|
|
|
buildDocsInSandbox = false;
|
|
|
|
maintainers = with lib.maintainers; [ nicoo ];
|
|
|
|
};
|
2021-01-08 15:57:48 -05:00
|
|
|
}
|