git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #10610 from joachifm/scsi-link-pm

nixos: set scsi link power policy using udev

commit0567714b99cfc906bd11c8458b195badc711812c authorDomen Kožar <domen@dev.si> dateMon 16 Nov 2015, 13:21 (11 years ago) parentb7651907b2b366
1 file changed+10−24
nixos/modules/tasks/scsi-link-power-management.nix+10−24
nixos/modules/tasks/scsi-link-power-management.nix+10−24
@@ -2,18 +2,19 @@
22
33with lib;
44
5+let cfg = config.powerManagement.scsiLinkPolicy; in
6+
57{
68 ###### interface
79
810 options = {
911
1012 powerManagement.scsiLinkPolicy = mkOption {
11− default = "";
12− example = "min_power";
13− type = types.str;
13+ default = null;
14+ type = types.nullOr (types.enum [ "min_power" "max_performance" "medium_power" ]);
1415 description = ''
15− Configure the SCSI link power management policy. By default,
16− the kernel configures "max_performance".
16+ SCSI link power management policy. The kernel default is
17+ "max_performance".
1718 '';
1819 };
1920
@@ -22,25 +23,10 @@ with lib;
2223
2324 ###### implementation
2425
25− config = mkIf (config.powerManagement.scsiLinkPolicy != "") {
26−
27− jobs."scsi-link-pm" =
28− { description = "SCSI Link Power Management Policy";
29−
30− startOn = "stopped udevtrigger";
31−
32− task = true;
33−
34− unitConfig.ConditionPathIsReadWrite = "/sys/class/scsi_host";
35−
36− script = ''
37− shopt -s nullglob
38− for x in /sys/class/scsi_host/host*/link_power_management_policy; do
39− echo ${config.powerManagement.scsiLinkPolicy} > $x
40− done
41− '';
42− };
43−
26+ config = mkIf (cfg != null) {
27+ services.udev.extraRules = ''
28+ SUBSYSTEM=="scsi_host", ACTION=="add", KERNEL=="host*", ATTR{link_power_management_policy}="${cfg}"
29+ '';
4430 };
4531
4632}