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`.
|
|
|
|
|
2023-10-09 19:29:22 +00: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-04-12 12:48:02 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
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
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
serviceConfig.WorkingDirectory = "";
|
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
|
|
|
};
|
2023-10-09 19:29:22 +00:00
|
|
|
|
|
|
|
# uses attributes of the linked package
|
|
|
|
meta = {
|
|
|
|
buildDocsInSandbox = false;
|
|
|
|
maintainers = with lib.maintainers; [ nicoo ];
|
|
|
|
};
|
2021-02-13 14:23:35 +00:00
|
|
|
}
|