forked from mirrors/nixpkgs
systemd: Run the powerManagement.* hooks on suspend/resume
Also, drop pm-utils. Systemd now takes care of suspend/resume.
This commit is contained in:
parent
38229da940
commit
c6d12257f1
|
@ -6,21 +6,6 @@ let
|
||||||
|
|
||||||
cfg = config.powerManagement;
|
cfg = config.powerManagement;
|
||||||
|
|
||||||
sleepHook = pkgs.writeScript "sleep-hook.sh"
|
|
||||||
''
|
|
||||||
#! ${pkgs.stdenv.shell}
|
|
||||||
action="$1"
|
|
||||||
case "$action" in
|
|
||||||
hibernate|suspend)
|
|
||||||
${cfg.powerDownCommands}
|
|
||||||
;;
|
|
||||||
thaw|resume)
|
|
||||||
${cfg.resumeCommands}
|
|
||||||
${cfg.powerUpCommands}
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
'';
|
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -79,13 +64,6 @@ in
|
||||||
# Enable the ACPI daemon. Not sure whether this is essential.
|
# Enable the ACPI daemon. Not sure whether this is essential.
|
||||||
services.acpid.enable = true;
|
services.acpid.enable = true;
|
||||||
|
|
||||||
environment.systemPackages = [ pkgs.pmutils ];
|
|
||||||
|
|
||||||
environment.etc = singleton
|
|
||||||
{ source = sleepHook;
|
|
||||||
target = "pm/sleep.d/00sleep-hook";
|
|
||||||
};
|
|
||||||
|
|
||||||
boot.kernelModules =
|
boot.kernelModules =
|
||||||
[ "acpi_cpufreq" "cpufreq_performance" "cpufreq_powersave" "cpufreq_ondemand"
|
[ "acpi_cpufreq" "cpufreq_performance" "cpufreq_powersave" "cpufreq_ondemand"
|
||||||
"cpufreq_conservative"
|
"cpufreq_conservative"
|
||||||
|
@ -93,7 +71,46 @@ in
|
||||||
|
|
||||||
powerManagement.cpuFreqGovernor = mkDefault "ondemand";
|
powerManagement.cpuFreqGovernor = mkDefault "ondemand";
|
||||||
powerManagement.scsiLinkPolicy = mkDefault "min_power";
|
powerManagement.scsiLinkPolicy = mkDefault "min_power";
|
||||||
|
|
||||||
|
# Service executed before suspending/hibernating.
|
||||||
|
boot.systemd.services."pre-sleep" =
|
||||||
|
{ description = "Pre-Sleep Actions";
|
||||||
|
wantedBy = [ "sleep.target" ];
|
||||||
|
before = [ "sleep.target" ];
|
||||||
|
script =
|
||||||
|
''
|
||||||
|
${cfg.powerDownCommands}
|
||||||
|
'';
|
||||||
|
serviceConfig.Type = "oneshot";
|
||||||
|
};
|
||||||
|
|
||||||
|
# Service executed before suspending/hibernating. There doesn't
|
||||||
|
# seem to be a good way to hook in a service to be executed after
|
||||||
|
# both suspend *and* hibernate, so have a separate one for each.
|
||||||
|
boot.systemd.services."post-suspend" =
|
||||||
|
{ description = "Post-Suspend Actions";
|
||||||
|
wantedBy = [ "suspend.target" ];
|
||||||
|
after = [ "systemd-suspend.service" ];
|
||||||
|
script =
|
||||||
|
''
|
||||||
|
${cfg.resumeCommands}
|
||||||
|
${cfg.powerUpCommands}
|
||||||
|
'';
|
||||||
|
serviceConfig.Type = "oneshot";
|
||||||
|
};
|
||||||
|
|
||||||
|
boot.systemd.services."post-hibernate" =
|
||||||
|
{ description = "Post-Hibernate Actions";
|
||||||
|
wantedBy = [ "hibernate.target" ];
|
||||||
|
after = [ "systemd-hibernate.service" ];
|
||||||
|
script =
|
||||||
|
''
|
||||||
|
${cfg.resumeCommands}
|
||||||
|
${cfg.powerUpCommands}
|
||||||
|
'';
|
||||||
|
serviceConfig.Type = "oneshot";
|
||||||
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue