2018-07-20 20:56:59 +00:00
|
|
|
{ config, lib, ... }:
|
2012-01-12 07:54:09 +00:00
|
|
|
|
2014-04-14 14:26:48 +00:00
|
|
|
with lib;
|
2012-01-12 07:54:09 +00:00
|
|
|
|
2018-05-04 17:33:42 +00:00
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.powerManagement.scsiLinkPolicy;
|
|
|
|
|
|
|
|
kernel = config.boot.kernelPackages.kernel;
|
|
|
|
|
|
|
|
allowedValues = [
|
|
|
|
"min_power"
|
|
|
|
"max_performance"
|
|
|
|
"medium_power"
|
|
|
|
"med_power_with_dipm"
|
|
|
|
];
|
|
|
|
|
|
|
|
in
|
2015-10-25 17:58:48 +00:00
|
|
|
|
2012-01-12 07:54:09 +00:00
|
|
|
{
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
2012-10-05 03:25:11 +00:00
|
|
|
|
2012-01-12 07:54:09 +00:00
|
|
|
powerManagement.scsiLinkPolicy = mkOption {
|
2015-10-25 17:58:48 +00:00
|
|
|
default = null;
|
2018-05-04 17:33:42 +00:00
|
|
|
type = types.nullOr (types.enum allowedValues);
|
2012-01-12 07:54:09 +00:00
|
|
|
description = ''
|
2015-10-25 17:58:48 +00:00
|
|
|
SCSI link power management policy. The kernel default is
|
|
|
|
"max_performance".
|
2018-05-04 17:33:42 +00:00
|
|
|
</para><para>
|
|
|
|
"med_power_with_dipm" is supported by kernel versions
|
|
|
|
4.15 and newer.
|
2012-01-12 07:54:09 +00:00
|
|
|
'';
|
|
|
|
};
|
2012-10-05 03:25:11 +00:00
|
|
|
|
2012-01-12 07:54:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
2015-10-25 17:58:48 +00:00
|
|
|
config = mkIf (cfg != null) {
|
2018-05-04 17:33:42 +00:00
|
|
|
|
|
|
|
assertions = singleton {
|
|
|
|
assertion = (cfg == "med_power_with_dipm") -> versionAtLeast kernel.version "4.15";
|
|
|
|
message = "med_power_with_dipm is not supported for kernels older than 4.15";
|
|
|
|
};
|
|
|
|
|
2015-10-25 17:58:48 +00:00
|
|
|
services.udev.extraRules = ''
|
|
|
|
SUBSYSTEM=="scsi_host", ACTION=="add", KERNEL=="host*", ATTR{link_power_management_policy}="${cfg}"
|
|
|
|
'';
|
2012-01-12 07:54:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|