about summary refs log tree commit diff
path: root/nixos/modules/tasks/scsi-link-power-management.nix
blob: 484c0a0186d7ffb14c3bd26dccb6d3a6b24c78d1 (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
{ config, lib, pkgs, ... }:

with lib;

let cfg = config.powerManagement.scsiLinkPolicy; in

{
  ###### interface

  options = {

    powerManagement.scsiLinkPolicy = mkOption {
      default = null;
      type = types.nullOr (types.enum [ "min_power" "max_performance" "medium_power" ]);
      description = ''
        SCSI link power management policy. The kernel default is
        "max_performance".
      '';
    };

  };


  ###### implementation

  config = mkIf (cfg != null) {
    services.udev.extraRules = ''
      SUBSYSTEM=="scsi_host", ACTION=="add", KERNEL=="host*", ATTR{link_power_management_policy}="${cfg}"
    '';
  };

}