Merge pull request #10610 from joachifm/scsi-link-pm
nixos: set scsi link power policy using udev
This commit is contained in:
commit
0567714b99
|
@ -2,18 +2,19 @@
|
|||
|
||||
with lib;
|
||||
|
||||
let cfg = config.powerManagement.scsiLinkPolicy; in
|
||||
|
||||
{
|
||||
###### interface
|
||||
|
||||
options = {
|
||||
|
||||
powerManagement.scsiLinkPolicy = mkOption {
|
||||
default = "";
|
||||
example = "min_power";
|
||||
type = types.str;
|
||||
default = null;
|
||||
type = types.nullOr (types.enum [ "min_power" "max_performance" "medium_power" ]);
|
||||
description = ''
|
||||
Configure the SCSI link power management policy. By default,
|
||||
the kernel configures "max_performance".
|
||||
SCSI link power management policy. The kernel default is
|
||||
"max_performance".
|
||||
'';
|
||||
};
|
||||
|
||||
|
@ -22,25 +23,10 @@ with lib;
|
|||
|
||||
###### implementation
|
||||
|
||||
config = mkIf (config.powerManagement.scsiLinkPolicy != "") {
|
||||
|
||||
jobs."scsi-link-pm" =
|
||||
{ description = "SCSI Link Power Management Policy";
|
||||
|
||||
startOn = "stopped udevtrigger";
|
||||
|
||||
task = true;
|
||||
|
||||
unitConfig.ConditionPathIsReadWrite = "/sys/class/scsi_host";
|
||||
|
||||
script = ''
|
||||
shopt -s nullglob
|
||||
for x in /sys/class/scsi_host/host*/link_power_management_policy; do
|
||||
echo ${config.powerManagement.scsiLinkPolicy} > $x
|
||||
done
|
||||
config = mkIf (cfg != null) {
|
||||
services.udev.extraRules = ''
|
||||
SUBSYSTEM=="scsi_host", ACTION=="add", KERNEL=="host*", ATTR{link_power_management_policy}="${cfg}"
|
||||
'';
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue