mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-16 14:54:29 +01:00
Convert "acpid"
svn path=/nixos/branches/fix-style/; revision=14358
This commit is contained in:
parent
8c5f0522e7
commit
1c43b4946b
2 changed files with 41 additions and 29 deletions
|
@ -2180,18 +2180,6 @@ in
|
|||
};
|
||||
|
||||
|
||||
powerManagement = {
|
||||
|
||||
enable = mkOption {
|
||||
default = false;
|
||||
description = "
|
||||
Whether to enable power management.
|
||||
";
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
nesting = {
|
||||
children = mkOption {
|
||||
default = [];
|
||||
|
@ -2222,6 +2210,8 @@ in
|
|||
(import ../system/activate-configuration.nix)
|
||||
(import ../upstart-jobs/default.nix)
|
||||
|
||||
(import ../upstart-jobs/acpid.nix) # ACPI daemon
|
||||
|
||||
# security
|
||||
(import ../system/sudo.nix)
|
||||
|
||||
|
|
|
@ -1,5 +1,22 @@
|
|||
{pkgs, config, ...}:
|
||||
|
||||
###### interface
|
||||
let
|
||||
inherit (pkgs.lib) mkOption mkIf;
|
||||
|
||||
options = {
|
||||
powerManagement = {
|
||||
|
||||
enable = mkOption {
|
||||
default = false;
|
||||
description = "Whether to enable power management (ACPI daemon)";
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
|
||||
###### implementation
|
||||
|
||||
let
|
||||
|
||||
acpiConfDir = pkgs.runCommand "acpi-events" {}
|
||||
|
@ -18,8 +35,6 @@ let
|
|||
}
|
||||
'';
|
||||
|
||||
events = [powerEvent lidEvent acEvent];
|
||||
|
||||
# Called when the power button is pressed.
|
||||
powerEvent =
|
||||
{ name = "power-button";
|
||||
|
@ -64,12 +79,18 @@ let
|
|||
'';
|
||||
};
|
||||
|
||||
events = [powerEvent lidEvent acEvent];
|
||||
|
||||
in
|
||||
|
||||
{
|
||||
name = "acpid";
|
||||
mkIf config.powerManagement.enable {
|
||||
require = [
|
||||
options
|
||||
];
|
||||
|
||||
extraPath = [pkgs.acpid];
|
||||
services = {
|
||||
extraJobs = [{
|
||||
name = "acpid";
|
||||
|
||||
job = ''
|
||||
description "ACPI daemon"
|
||||
|
@ -79,5 +100,6 @@ in
|
|||
|
||||
respawn ${pkgs.acpid}/sbin/acpid --foreground --confdir ${acpiConfDir}
|
||||
'';
|
||||
|
||||
}];
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue