mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-13 05:05:29 +03:00
nixos/powertop: add hooks to fix incorrect configurations
This commit is contained in:
parent
04e40bca2a
commit
dab01f875c
1 changed files with 34 additions and 1 deletions
|
@ -13,7 +13,38 @@ in
|
||||||
{
|
{
|
||||||
###### interface
|
###### interface
|
||||||
|
|
||||||
options.powerManagement.powertop.enable = mkEnableOption "powertop auto tuning on startup";
|
options.powerManagement.powertop = {
|
||||||
|
enable = mkEnableOption "powertop auto tuning on startup";
|
||||||
|
|
||||||
|
preStart = mkOption {
|
||||||
|
type = types.lines;
|
||||||
|
default = "";
|
||||||
|
description = ''
|
||||||
|
Shell commands executed before `powertop` is started.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
postStart = mkOption {
|
||||||
|
type = types.lines;
|
||||||
|
default = "";
|
||||||
|
example = ''
|
||||||
|
''${lib.getExe' config.systemd.package "udevadm"} trigger -c bind -s usb -a idVendor=046d -a idProduct=c08c
|
||||||
|
'';
|
||||||
|
description = ''
|
||||||
|
Shell commands executed after `powertop` is started.
|
||||||
|
|
||||||
|
This can be used to workaround problematic configurations. For example,
|
||||||
|
you can retrigger an `udev` rule to disable power saving on unsupported
|
||||||
|
USB devices:
|
||||||
|
```
|
||||||
|
services.udev.extraRules = ''''
|
||||||
|
# disable USB auto suspend for Logitech, Inc. G PRO Gaming Mouse
|
||||||
|
ACTION=="bind", SUBSYSTEM=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c08c", TEST=="power/control", ATTR{power/control}="on"
|
||||||
|
'''';
|
||||||
|
```
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
###### implementation
|
###### implementation
|
||||||
|
|
||||||
|
@ -24,6 +55,8 @@ in
|
||||||
after = [ "multi-user.target" ];
|
after = [ "multi-user.target" ];
|
||||||
description = "Powertop tunings";
|
description = "Powertop tunings";
|
||||||
path = [ pkgs.kmod ];
|
path = [ pkgs.kmod ];
|
||||||
|
preStart = cfg.preStart;
|
||||||
|
postStart = cfg.postStart;
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "oneshot";
|
Type = "oneshot";
|
||||||
RemainAfterExit = "yes";
|
RemainAfterExit = "yes";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue