* Move power management configuration into a separate module from
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
This commit is contained in:
parent
c1b008b4e3
commit
1affc9168e
63
modules/config/power-management.nix
Normal file
63
modules/config/power-management.nix
Normal file
@ -0,0 +1,63 @@
|
||||
{ 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";
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
}
|
@ -5,6 +5,7 @@
|
||||
./config/networking.nix
|
||||
./config/no-x-libs.nix
|
||||
./config/nsswitch.nix
|
||||
./config/power-management.nix
|
||||
./config/system-path.nix
|
||||
./config/timezone.nix
|
||||
./config/unix-odbc-drivers.nix
|
||||
|
@ -60,11 +60,11 @@ in
|
||||
|
||||
options = {
|
||||
|
||||
powerManagement = {
|
||||
services.acpid = {
|
||||
|
||||
enable = mkOption {
|
||||
default = false;
|
||||
description = "Whether to enable power management (ACPI daemon)";
|
||||
description = "Whether to enable the ACPI daemon.";
|
||||
};
|
||||
|
||||
};
|
||||
@ -74,7 +74,7 @@ in
|
||||
|
||||
###### implementation
|
||||
|
||||
config = mkIf config.powerManagement.enable {
|
||||
config = mkIf config.services.acpid.enable {
|
||||
|
||||
jobs.acpid =
|
||||
{ description = "ACPI daemon";
|
||||
|
@ -48,10 +48,9 @@ in
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
|
||||
# !!! move pmutils somewhere else
|
||||
environment.systemPackages = [hal pkgs.pmutils];
|
||||
environment.systemPackages = [ hal ];
|
||||
|
||||
services.hal.packages = [hal pkgs.hal_info];
|
||||
services.hal.packages = [ hal pkgs.hal_info ];
|
||||
|
||||
users.extraUsers = singleton
|
||||
{ name = "haldaemon";
|
||||
@ -67,7 +66,7 @@ in
|
||||
jobs.hal =
|
||||
{ description = "HAL daemon";
|
||||
|
||||
startOn = "started dbus" + optionalString config.powerManagement.enable " and started acpid";
|
||||
startOn = "started dbus" + optionalString config.services.acpid.enable " and started acpid";
|
||||
|
||||
environment =
|
||||
{ # !!! HACK? These environment variables manipulated inside
|
||||
@ -113,4 +112,4 @@ in
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user