depot/third_party/nixpkgs/nixos/modules/services/hardware/auto-cpufreq.nix
Default email 159e378cbb Project import generated by Copybara.
GitOrigin-RevId: c04d5652cfa9742b1d519688f65d1bbccea9eb7e
2024-09-19 17:19:46 +03:00

50 lines
1.4 KiB
Nix

{ config, lib, pkgs, ... }:
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 = lib.mkEnableOption "auto-cpufreq daemon";
settings = lib.mkOption {
description = ''
Configuration for `auto-cpufreq`.
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).
'';
default = {};
type = lib.types.submodule { freeformType = format.type; };
};
};
};
config = lib.mkIf cfg.enable {
environment.systemPackages = [ pkgs.auto-cpufreq ];
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 ];
serviceConfig.WorkingDirectory = "";
serviceConfig.ExecStart = [
""
"${lib.getExe pkgs.auto-cpufreq} --daemon --config ${cfgFile}"
];
};
};
};
# uses attributes of the linked package
meta = {
buildDocsInSandbox = false;
maintainers = with lib.maintainers; [ nicoo ];
};
}