mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-12-27 05:43:50 +03:00
29027fd1e1
Using pkgs.lib on the spine of module evaluation is problematic because the pkgs argument depends on the result of module evaluation. To prevent an infinite recursion, pkgs and some of the modules are evaluated twice, which is inefficient. Using ‘with lib’ prevents this problem.
47 lines
910 B
Nix
47 lines
910 B
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
{
|
|
###### interface
|
|
|
|
options = {
|
|
|
|
powerManagement.scsiLinkPolicy = mkOption {
|
|
default = "";
|
|
example = "min_power";
|
|
type = types.str;
|
|
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;
|
|
|
|
unitConfig.ConditionPathIsReadWrite = "/sys/class/scsi_host";
|
|
|
|
script = ''
|
|
shopt -s nullglob
|
|
for x in /sys/class/scsi_host/host*/link_power_management_policy; do
|
|
echo ${config.powerManagement.scsiLinkPolicy} > $x
|
|
done
|
|
'';
|
|
};
|
|
|
|
};
|
|
|
|
}
|