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