speechd: use socket activation

This commit is contained in:
Peter Kling 2025-01-19 14:33:35 +01:00 committed by Jan Tojnar
parent 5537661d08
commit 089fa2b542
3 changed files with 18 additions and 4 deletions

View file

@ -7,7 +7,6 @@
let
cfg = config.services.speechd;
inherit (lib)
getExe
mkEnableOption
mkIf
mkPackageOption
@ -21,12 +20,12 @@ in
package = mkPackageOption pkgs "speechd" { };
};
# FIXME: speechd 0.12 (or whatever the next version is)
# will support socket activation, so switch to that once it's out.
config = mkIf cfg.enable {
environment = {
systemPackages = [ cfg.package ];
sessionVariables.SPEECHD_CMD = getExe cfg.package;
};
systemd.packages = [ cfg.package ];
# have to set `wantedBy` since `systemd.packages` ignores `[Install]`
systemd.user.sockets.speech-dispatcher.wantedBy = [ "sockets.target" ];
};
}

View file

@ -1,3 +1,13 @@
diff --git a/speech-dispatcher.service.in b/speech-dispatcher.service.in
index 6280f2d9..edf6024c 100644
--- a/speech-dispatcher.service.in
+++ b/speech-dispatcher.service.in
@@ -20,4 +20,4 @@ Requires=speech-dispatcher.socket
[Service]
Type=simple
ExecStart=@bindir@/speech-dispatcher -s -t 0
-ExecReload=/bin/kill -HUP $MAINPID
+ExecReload=@utillinux@/bin/kill -HUP $MAINPID
diff --git a/speech-dispatcherd.service.in b/speech-dispatcherd.service.in
index ab14b99d..12521b1b 100644
--- a/speech-dispatcherd.service.in

View file

@ -9,6 +9,7 @@
itstool,
libtool,
texinfo,
systemdMinimal,
util-linux,
autoreconfHook,
glib,
@ -79,6 +80,9 @@ stdenv.mkDerivation (finalAttrs: {
libpulseaudio
python
]
++ lib.optionals stdenv.hostPlatform.isLinux [
systemdMinimal # libsystemd
]
++ lib.optionals withAlsa [
alsa-lib
]
@ -103,6 +107,7 @@ stdenv.mkDerivation (finalAttrs: {
# Audio method falls back from left to right.
"--with-default-audio-method=\"libao,pulse,alsa,oss\""
"--with-systemdsystemunitdir=${placeholder "out"}/lib/systemd/system"
"--with-systemduserunitdir=${placeholder "out"}/lib/systemd/user"
]
++ lib.optionals withPulse [
"--with-pulse"