Convert "acpid"
svn path=/nixos/branches/fix-style/; revision=14358
This commit is contained in:
parent
8c5f0522e7
commit
1c43b4946b
@ -2180,18 +2180,6 @@ in
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
powerManagement = {
|
|
||||||
|
|
||||||
enable = mkOption {
|
|
||||||
default = false;
|
|
||||||
description = "
|
|
||||||
Whether to enable power management.
|
|
||||||
";
|
|
||||||
};
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
nesting = {
|
nesting = {
|
||||||
children = mkOption {
|
children = mkOption {
|
||||||
default = [];
|
default = [];
|
||||||
@ -2222,6 +2210,8 @@ in
|
|||||||
(import ../system/activate-configuration.nix)
|
(import ../system/activate-configuration.nix)
|
||||||
(import ../upstart-jobs/default.nix)
|
(import ../upstart-jobs/default.nix)
|
||||||
|
|
||||||
|
(import ../upstart-jobs/acpid.nix) # ACPI daemon
|
||||||
|
|
||||||
# security
|
# security
|
||||||
(import ../system/sudo.nix)
|
(import ../system/sudo.nix)
|
||||||
|
|
||||||
|
@ -1,5 +1,22 @@
|
|||||||
{pkgs, config, ...}:
|
{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
|
let
|
||||||
|
|
||||||
acpiConfDir = pkgs.runCommand "acpi-events" {}
|
acpiConfDir = pkgs.runCommand "acpi-events" {}
|
||||||
@ -17,9 +34,7 @@ let
|
|||||||
in pkgs.lib.concatMapStrings f events
|
in pkgs.lib.concatMapStrings f events
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
events = [powerEvent lidEvent acEvent];
|
|
||||||
|
|
||||||
# Called when the power button is pressed.
|
# Called when the power button is pressed.
|
||||||
powerEvent =
|
powerEvent =
|
||||||
{ name = "power-button";
|
{ name = "power-button";
|
||||||
@ -29,7 +44,7 @@ let
|
|||||||
#! ${pkgs.bash}/bin/sh
|
#! ${pkgs.bash}/bin/sh
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
# Called when the laptop lid is opened/closed.
|
# Called when the laptop lid is opened/closed.
|
||||||
lidEvent =
|
lidEvent =
|
||||||
{ name = "lid";
|
{ name = "lid";
|
||||||
@ -47,7 +62,7 @@ let
|
|||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
# Called when the AC power is connected or disconnected.
|
# Called when the AC power is connected or disconnected.
|
||||||
acEvent =
|
acEvent =
|
||||||
{ name = "ac-power";
|
{ name = "ac-power";
|
||||||
@ -64,20 +79,27 @@ let
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
events = [powerEvent lidEvent acEvent];
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
{
|
mkIf config.powerManagement.enable {
|
||||||
name = "acpid";
|
require = [
|
||||||
|
options
|
||||||
extraPath = [pkgs.acpid];
|
];
|
||||||
|
|
||||||
job = ''
|
|
||||||
description "ACPI daemon"
|
|
||||||
|
|
||||||
start on udev
|
services = {
|
||||||
stop on shutdown
|
extraJobs = [{
|
||||||
|
name = "acpid";
|
||||||
|
|
||||||
respawn ${pkgs.acpid}/sbin/acpid --foreground --confdir ${acpiConfDir}
|
job = ''
|
||||||
'';
|
description "ACPI daemon"
|
||||||
|
|
||||||
|
start on udev
|
||||||
|
stop on shutdown
|
||||||
|
|
||||||
|
respawn ${pkgs.acpid}/sbin/acpid --foreground --confdir ${acpiConfDir}
|
||||||
|
'';
|
||||||
|
}];
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user