2012-01-12 07:54:09 +00:00
|
|
|
{ config, pkgs, ... }:
|
|
|
|
|
|
|
|
with pkgs.lib;
|
|
|
|
|
|
|
|
{
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
2012-10-05 03:25:11 +00:00
|
|
|
|
2012-01-12 07:54:09 +00:00
|
|
|
powerManagement.scsiLinkPolicy = mkOption {
|
|
|
|
default = "";
|
|
|
|
example = "min_power";
|
2012-01-13 13:26:52 +00:00
|
|
|
type = types.uniq types.string;
|
2012-01-12 07:54:09 +00:00
|
|
|
description = ''
|
|
|
|
Configure the scsi link power management policy. By default,
|
|
|
|
the kernel configures "max_performance".
|
|
|
|
'';
|
|
|
|
};
|
2012-10-05 03:25:11 +00: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 03:25:11 +00:00
|
|
|
{ description = "SCSI Link Power Management Policy";
|
2012-01-12 07:54:09 +00:00
|
|
|
|
2012-10-05 03:25:11 +00:00
|
|
|
startOn = "stopped udevtrigger";
|
2012-01-12 07:54:09 +00:00
|
|
|
|
|
|
|
task = true;
|
|
|
|
|
|
|
|
script = ''
|
2012-10-05 03:25:11 +00: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 03:25:11 +00:00
|
|
|
|
2012-01-12 07:54:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|