2012-01-12 08:54:09 +01:00
|
|
|
{ config, pkgs, ... }:
|
|
|
|
|
|
|
|
with pkgs.lib;
|
|
|
|
|
|
|
|
{
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
2012-10-05 05:25:11 +02:00
|
|
|
|
2012-01-12 08:54:09 +01:00
|
|
|
powerManagement.scsiLinkPolicy = mkOption {
|
|
|
|
default = "";
|
|
|
|
example = "min_power";
|
2013-10-30 11:02:04 +01:00
|
|
|
type = types.str;
|
2012-01-12 08:54:09 +01:00
|
|
|
description = ''
|
2013-08-10 23:07:13 +02:00
|
|
|
Configure the SCSI link power management policy. By default,
|
2012-01-12 08:54:09 +01:00
|
|
|
the kernel configures "max_performance".
|
|
|
|
'';
|
|
|
|
};
|
2012-10-05 05:25:11 +02:00
|
|
|
|
2012-01-12 08:54:09 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf (config.powerManagement.scsiLinkPolicy != "") {
|
|
|
|
|
2012-03-17 20:22:22 +01:00
|
|
|
jobs."scsi-link-pm" =
|
2012-10-05 05:25:11 +02:00
|
|
|
{ description = "SCSI Link Power Management Policy";
|
2012-01-12 08:54:09 +01:00
|
|
|
|
2012-10-05 05:25:11 +02:00
|
|
|
startOn = "stopped udevtrigger";
|
2012-01-12 08:54:09 +01:00
|
|
|
|
|
|
|
task = true;
|
|
|
|
|
2013-11-26 18:17:12 +01:00
|
|
|
unitConfig.ConditionPathIsReadWrite = "/sys/class/scsi_host";
|
|
|
|
|
2012-01-12 08:54:09 +01:00
|
|
|
script = ''
|
2012-10-05 05:25:11 +02:00
|
|
|
shopt -s nullglob
|
2012-01-12 08:54:09 +01:00
|
|
|
for x in /sys/class/scsi_host/host*/link_power_management_policy; do
|
|
|
|
echo ${config.powerManagement.scsiLinkPolicy} > $x
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
};
|
2012-10-05 05:25:11 +02:00
|
|
|
|
2012-01-12 08:54:09 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|