1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6 cfg = config.powerManagement.powertop;
7in {
8 ###### interface
9
10 options.powerManagement.powertop.enable = mkEnableOption "powertop auto tuning on startup";
11
12 ###### implementation
13
14 config = mkIf (cfg.enable) {
15 systemd.services = {
16 powertop = {
17 wantedBy = [ "multi-user.target" ];
18 description = "Powertop tunings";
19 path = [ pkgs.kmod ];
20 serviceConfig = {
21 Type = "oneshot";
22 RemainAfterExit = "yes";
23 ExecStart = "${pkgs.powertop}/bin/powertop --auto-tune";
24 };
25 };
26 };
27 };
28}