mirror of
https://github.com/NixOS/nixpkgs
synced 2024-10-19 03:47:13 -04:00
1affc9168e
the acpid service. * Add a pm-utils hook to allow commands to be executed when the system suspends/resumes etc. svn path=/nixos/branches/upstart-0.6/; revision=18353
64 lines
1.1 KiB
Nix
64 lines
1.1 KiB
Nix
{ config, pkgs, ... }:
|
|
|
|
with pkgs.lib;
|
|
|
|
let
|
|
|
|
cfg = config.powerManagement;
|
|
|
|
sleepHook = pkgs.writeScript "sleep-hook.sh"
|
|
''
|
|
#! ${pkgs.stdenv.shell}
|
|
action="$1"
|
|
if [ "$action" = "resume" ]; then
|
|
${cfg.resumeCommands}
|
|
fi
|
|
'';
|
|
|
|
in
|
|
|
|
{
|
|
|
|
###### interface
|
|
|
|
options = {
|
|
|
|
powerManagement = {
|
|
|
|
enable = mkOption {
|
|
default = false;
|
|
description =
|
|
''
|
|
Whether to enable power management. This includes support
|
|
for suspend-to-RAM and powersave features on laptops.
|
|
'';
|
|
};
|
|
|
|
resumeCommands = mkOption {
|
|
default = "";
|
|
description = "Commands executed after the system resumes from suspend-to-RAM.";
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
###### implementation
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
# Enable the ACPI daemon. Not sure whether this is essential.
|
|
services.acpid.enable = true;
|
|
|
|
environment.systemPackages = [ pkgs.pmutils ];
|
|
|
|
environment.etc = singleton
|
|
{ source = sleepHook;
|
|
target = "pm/sleep.d/00sleep-hook";
|
|
};
|
|
|
|
};
|
|
|
|
}
|