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