2011-07-25 02:45:52 +02:00
|
|
|
# Upower daemon.
|
|
|
|
|
2014-04-14 16:26:48 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
2011-07-25 02:45:52 +02:00
|
|
|
|
2014-04-14 16:26:48 +02:00
|
|
|
with lib;
|
2011-07-25 02:45:52 +02:00
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2011-07-25 02:45:52 +02:00
|
|
|
options = {
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2011-07-25 02:45:52 +02:00
|
|
|
services.upower = {
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2011-07-25 02:45:52 +02:00
|
|
|
enable = mkOption {
|
2013-10-30 17:37:45 +01:00
|
|
|
type = types.bool;
|
2011-07-25 02:45:52 +02:00
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Whether to enable Upower, a DBus service that provides power
|
|
|
|
management support to applications.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2011-07-25 02:45:52 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2011-07-25 02:45:52 +02:00
|
|
|
config = mkIf config.services.upower.enable {
|
|
|
|
|
|
|
|
environment.systemPackages = [ pkgs.upower ];
|
|
|
|
|
|
|
|
services.dbus.packages = [ pkgs.upower ];
|
|
|
|
|
2011-08-24 23:24:39 +02:00
|
|
|
services.udev.packages = [ pkgs.upower ];
|
|
|
|
|
2013-01-16 12:33:18 +01:00
|
|
|
systemd.services.upower =
|
2012-10-04 22:38:31 +02:00
|
|
|
{ description = "Power Management Daemon";
|
|
|
|
path = [ pkgs.glib ]; # needed for gdbus
|
|
|
|
serviceConfig =
|
|
|
|
{ Type = "dbus";
|
|
|
|
BusName = "org.freedesktop.UPower";
|
|
|
|
ExecStart = "@${pkgs.upower}/libexec/upowerd upowerd";
|
|
|
|
};
|
|
|
|
};
|
2012-08-21 17:29:59 +02:00
|
|
|
|
2011-09-06 13:18:36 +02:00
|
|
|
system.activationScripts.upower =
|
|
|
|
''
|
|
|
|
mkdir -m 0755 -p /var/lib/upower
|
|
|
|
'';
|
|
|
|
|
2012-10-05 03:58:40 +02:00
|
|
|
# The upower daemon seems to get stuck after doing a suspend
|
|
|
|
# (i.e. subsequent suspend requests will say "Sleep has already
|
|
|
|
# been requested and is pending"). So as a workaround, restart
|
|
|
|
# the daemon.
|
|
|
|
powerManagement.resumeCommands =
|
|
|
|
''
|
2013-01-16 13:17:57 +01:00
|
|
|
${config.systemd.package}/bin/systemctl try-restart upower
|
2012-10-05 03:58:40 +02:00
|
|
|
'';
|
|
|
|
|
2011-07-25 02:45:52 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|