nixos/auto-cpufreq: Add configuration support.

This commit is contained in:
nicoo 2023-03-28 19:09:54 +00:00
parent 82279daf52
commit deab2b3bf7

View File

@ -2,21 +2,39 @@
with lib;
let
cfg = config.services.auto-cpufreq;
cfgFilename = "auto-cpufreq.conf";
cfgFile = format.generate cfgFilename cfg.settings;
format = pkgs.formats.ini {};
in {
options = {
services.auto-cpufreq = {
enable = mkEnableOption (lib.mdDoc "auto-cpufreq daemon");
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; };
};
};
};
config = mkIf cfg.enable {
environment.systemPackages = [ pkgs.auto-cpufreq ];
environment.etc.${cfgFilename}.source = cfgFile;
systemd = {
packages = [ pkgs.auto-cpufreq ];
services.auto-cpufreq = {
# Workaround for https://github.com/NixOS/nixpkgs/issues/81138
wantedBy = [ "multi-user.target" ];
restartTriggers = [ cfgFile ];
path = with pkgs; [ bash coreutils ];
};
};