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;
|
with lib;
|
||||||
|
|
||||||
|
let cfg = config.powerManagement.scsiLinkPolicy; in
|
||||||
|
|
||||||
{
|
{
|
||||||
###### interface
|
###### interface
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
|
|
||||||
powerManagement.scsiLinkPolicy = mkOption {
|
powerManagement.scsiLinkPolicy = mkOption {
|
||||||
default = "";
|
default = null;
|
||||||
example = "min_power";
|
type = types.nullOr (types.enum [ "min_power" "max_performance" "medium_power" ]);
|
||||||
type = types.str;
|
|
||||||
description = ''
|
description = ''
|
||||||
Configure the SCSI link power management policy. By default,
|
SCSI link power management policy. The kernel default is
|
||||||
the kernel configures "max_performance".
|
"max_performance".
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -22,25 +23,10 @@ with lib;
|
|||||||
|
|
||||||
###### implementation
|
###### implementation
|
||||||
|
|
||||||
config = mkIf (config.powerManagement.scsiLinkPolicy != "") {
|
config = mkIf (cfg != null) {
|
||||||
|
services.udev.extraRules = ''
|
||||||
jobs."scsi-link-pm" =
|
SUBSYSTEM=="scsi_host", ACTION=="add", KERNEL=="host*", ATTR{link_power_management_policy}="${cfg}"
|
||||||
{ 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
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user