From 6b9764ec5af727db0c9da92c57742b79d7a3cd6a Mon Sep 17 00:00:00 2001 From: h7x4 Date: Tue, 15 Sep 2026 13:36:26 +0900 Subject: [PATCH] nixos/tests/speechd: init This test ensures that the speechd module evals correctly behind its `mkIf` guard, and verifies that configuration is picked up correctly. It unfortunately does not test integration with other systems like pipewire, but the test is better than nothing in it's current state. --- nixos/tests/all-tests.nix | 1 + nixos/tests/speechd.nix | 49 +++++++++++++++++++++++++++++ pkgs/by-name/sp/speechd/package.nix | 3 ++ 3 files changed, 53 insertions(+) create mode 100644 nixos/tests/speechd.nix diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index a02c12f93e92..15774caa00e9 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -1717,6 +1717,7 @@ in sonic-server = runTest ./sonic-server.nix; spacecookie = runTest ./spacecookie.nix; spark = handleTestOn [ "x86_64-linux" "aarch64-linux" ] ./spark { }; + speechd = runTest ./speechd.nix; speedtest-tracker = runTest ./speedtest-tracker.nix; spiped = runTest ./spiped.nix; spire = runTest ./spire.nix; diff --git a/nixos/tests/speechd.nix b/nixos/tests/speechd.nix new file mode 100644 index 000000000000..4988b24b3732 --- /dev/null +++ b/nixos/tests/speechd.nix @@ -0,0 +1,49 @@ +{ lib, ... }: +{ + name = "speechd"; + meta.maintainers = [ lib.maintainers.h7x4 ]; + + nodes.machine = + { pkgs, ... }: + { + imports = [ ./common/user-account.nix ]; + + environment.systemPackages = [ pkgs.speechd ]; + + # Without a real sound card, libao (speech-dispatcher's audio backend) + # fails to open any device. libao's built-in "null" driver always succeeds. + environment.etc."libao.conf".text = '' + default_driver=null + ''; + + services.speechd = { + enable = true; + config = '' + AddModule "testmodule" "sd_generic" "testmodule.conf" + DefaultModule "testmodule" + ''; + modules.testmodule = '' + AddVoice "en" "male1" "testmodule_voice" + GenericLanguage "en" "en" + GenericExecuteSynth "echo \'$DATA\' >> /tmp/speechd-spoken.txt" + ''; + }; + }; + + testScript = + { nodes, ... }: + let + user = nodes.machine.users.users.alice; + uid = toString user.uid; + aliceRun = command: "su - ${user.name} -c 'XDG_RUNTIME_DIR=/run/user/${uid} ${command}'"; + in + '' + machine.wait_for_unit("multi-user.target") + machine.succeed("loginctl enable-linger ${user.name}") + machine.wait_for_unit("user@${uid}.service") + machine.wait_for_unit("speech-dispatcher.socket", "${user.name}") + + machine.succeed("${aliceRun "spd-say 'hello'"}") + machine.wait_until_succeeds("grep -q 'hello' /tmp/speechd-spoken.txt") + ''; +} diff --git a/pkgs/by-name/sp/speechd/package.nix b/pkgs/by-name/sp/speechd/package.nix index e63b5db36d92..644004c68325 100644 --- a/pkgs/by-name/sp/speechd/package.nix +++ b/pkgs/by-name/sp/speechd/package.nix @@ -33,6 +33,7 @@ withPico ? true, picotts, libsOnly ? false, + nixosTests, }: let @@ -152,6 +153,8 @@ stdenv.mkDerivation (finalAttrs: { enableParallelBuilding = true; + passthru.tests.nixos = nixosTests.speechd; + meta = { description = "Common interface to speech synthesis" + lib.optionalString libsOnly " - client libraries only";