at 25.11-pre 1.4 kB view raw
1{ 2 config, 3 lib, 4 pkgs, 5 ... 6}: 7let 8 cfg = config.services.auto-cpufreq; 9 cfgFilename = "auto-cpufreq.conf"; 10 cfgFile = format.generate cfgFilename cfg.settings; 11 12 format = pkgs.formats.ini { }; 13in 14{ 15 options = { 16 services.auto-cpufreq = { 17 enable = lib.mkEnableOption "auto-cpufreq daemon"; 18 19 settings = lib.mkOption { 20 description = '' 21 Configuration for `auto-cpufreq`. 22 23 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). 24 ''; 25 26 default = { }; 27 type = lib.types.submodule { freeformType = format.type; }; 28 }; 29 }; 30 }; 31 32 config = lib.mkIf cfg.enable { 33 environment.systemPackages = [ pkgs.auto-cpufreq ]; 34 35 systemd = { 36 packages = [ pkgs.auto-cpufreq ]; 37 services.auto-cpufreq = { 38 # Workaround for https://github.com/NixOS/nixpkgs/issues/81138 39 wantedBy = [ "multi-user.target" ]; 40 path = with pkgs; [ 41 bash 42 coreutils 43 ]; 44 45 serviceConfig.WorkingDirectory = ""; 46 serviceConfig.ExecStart = [ 47 "" 48 "${lib.getExe pkgs.auto-cpufreq} --daemon --config ${cfgFile}" 49 ]; 50 }; 51 }; 52 }; 53 54 # uses attributes of the linked package 55 meta = { 56 buildDocsInSandbox = false; 57 maintainers = with lib.maintainers; [ nicoo ]; 58 }; 59}