Skip to content
Permalink
Browse files

acpid socket

  • Loading branch information
peterhoeg committed Jul 12, 2018
1 parent dae9cf6 commit 0e7f961288af740afd45a7c358a96748891dbb80
Showing with 25 additions and 10 deletions.
  1. +25 −10 nixos/modules/services/hardware/acpid.nix
@@ -4,6 +4,8 @@ with lib;

let

cfg = config.services.acpid;

canonicalHandlers = {
powerEvent = {
event = "button/power.*";
@@ -53,6 +55,12 @@ in
description = "Whether to enable the ACPI daemon.";
};

socketActivation = mkOption {
type = types.bool;
default = true;
description = "Only run acpid when connections are made to its socket.";
};

logEvents = mkOption {
type = types.bool;
default = false;
@@ -129,28 +137,35 @@ in

###### implementation

config = mkIf config.services.acpid.enable {
config = mkIf cfg.enable {

systemd.services.acpid = {
systemd.services.acpid = rec {
description = "ACPI Daemon";

wantedBy = [ "multi-user.target" ];
after = [ "systemd-udev-settle.service" ];

path = [ pkgs.acpid ];
wantedBy = lib.mkIf (! cfg.socketActivation) [ "multi-user.target" ];
requires = [ "acpid.socket" ];
after = requires;

serviceConfig = {
Type = "forking";
ExecStart = "${pkgs.acpid}/bin/acpid --foreground --netlink ${optionalString cfg.logEvents "--logevents"} --confdir ${acpiConfDir} --nosocket";
};

unitConfig = {
ConditionVirtualization = "!systemd-nspawn";
ConditionPathExists = [ "/proc/acpi" ];
};

script = "acpid ${optionalString config.services.acpid.logEvents "--logevents"} --confdir ${acpiConfDir}";
};

};
systemd.sockets.acpid = {
description = "ACPI Daemon";

wantedBy = lib.mkIf cfg.socketActivation [ "sockets.target" ];

socketConfig = {
Accept = true;
StandardInput = "socket";
ListenStream = "/run/acpid.socket";
};
};
};
}

0 comments on commit 0e7f961

Please sign in to comment.
You can’t perform that action at this time.