2018-07-20 23:56:59 +03:00
|
|
|
{ config, lib, ... }:
|
2012-01-12 11:54:09 +04:00
|
|
|
|
2014-04-14 18:26:48 +04:00
|
|
|
with lib;
|
2012-01-12 11:54:09 +04:00
|
|
|
|
2018-05-04 20:33:42 +03: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 20:58:48 +03:00
|
|
|
|
2012-01-12 11:54:09 +04:00
|
|
|
{
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
2012-10-05 07:25:11 +04:00
|
|
|
|
2012-01-12 11:54:09 +04:00
|
|
|
powerManagement.scsiLinkPolicy = mkOption {
|
2015-10-25 20:58:48 +03:00
|
|
|
default = null;
|
2018-05-04 20:33:42 +03:00
|
|
|
type = types.nullOr (types.enum allowedValues);
|
2012-01-12 11:54:09 +04:00
|
|
|
description = ''
|
2015-10-25 20:58:48 +03:00
|
|
|
SCSI link power management policy. The kernel default is
|
|
|
|
"max_performance".
|
2018-05-04 20:33:42 +03:00
|
|
|
</para><para>
|
|
|
|
"med_power_with_dipm" is supported by kernel versions
|
|
|
|
4.15 and newer.
|
2012-01-12 11:54:09 +04:00
|
|
|
'';
|
|
|
|
};
|
2012-10-05 07:25:11 +04:00
|
|
|
|
2012-01-12 11:54:09 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
2015-10-25 20:58:48 +03:00
|
|
|
config = mkIf (cfg != null) {
|
2018-05-04 20:33:42 +03: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 20:58:48 +03:00
|
|
|
services.udev.extraRules = ''
|
|
|
|
SUBSYSTEM=="scsi_host", ACTION=="add", KERNEL=="host*", ATTR{link_power_management_policy}="${cfg}"
|
|
|
|
'';
|
2012-01-12 11:54:09 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|