summary refs log tree commit diff
path: root/nixos/modules/tasks/scsi-link-power-management.nix
blob: 4ab67aee395639b7c5b38b613c7f7b3bdf8de7ae (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
{ config, pkgs, ... }:

with pkgs.lib;

{
  ###### interface

  options = {

    powerManagement.scsiLinkPolicy = mkOption {
      default = "";
      example = "min_power";
      type = types.uniq types.string;
      description = ''
        Configure the SCSI link power management policy. By default,
        the kernel configures "max_performance".
      '';
    };

  };


  ###### implementation

  config = mkIf (config.powerManagement.scsiLinkPolicy != "") {

    jobs."scsi-link-pm" =
      { description = "SCSI Link Power Management Policy";

        startOn = "stopped udevtrigger";

        task = true;

        script = ''
          shopt -s nullglob
          for x in /sys/class/scsi_host/host*/link_power_management_policy; do
            echo ${config.powerManagement.scsiLinkPolicy} > $x
          done
        '';
      };

  };

}