2012-01-12 07:54:09 +00:00
|
|
|
{ config, pkgs, ... }:
|
|
|
|
|
|
|
|
with pkgs.lib;
|
|
|
|
|
|
|
|
{
|
|
|
|
###### 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;
|
|
|
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
|
|
|
}
|