nixos-configs/nixosModules/wyoming-plus/default.nix

50 lines
1.6 KiB
Nix
Raw Normal View History

{
2024-09-01 19:19:30 -04:00
config,
lib,
pkgs,
...
}: let
inherit (lib.modules) mkForce mkIf mkOverride;
inherit (lib.strings) concatMapStringsSep concatStringsSep optionalString;
2024-09-01 19:19:30 -04:00
2024-09-12 18:21:31 -04:00
cfg = config.services.wyoming;
2024-09-01 19:19:30 -04:00
in {
2024-09-12 18:21:31 -04:00
config = let
forkedPkg = (import ./pkgs {inherit pkgs;}).wyoming-openwakeword;
2024-09-12 18:21:31 -04:00
in {
systemd.services = mkIf (cfg.openwakeword.enable) {
wyoming-openwakeword.serviceConfig = {
MemoryDenyWriteExecute = mkForce (cfg.openwakeword.package != forkedPkg);
2024-09-12 18:21:31 -04:00
# changes according to https://github.com/rhasspy/wyoming-openwakeword/pull/27
ExecStart = mkForce (concatStringsSep " " [
"${cfg.openwakeword.package}/bin/wyoming-openwakeword"
2024-09-12 18:21:31 -04:00
"--uri ${cfg.openwakeword.uri}"
"--threshold ${cfg.openwakeword.threshold}"
2024-09-12 18:21:31 -04:00
(concatMapStringsSep " "
(dir: "--custom-model-dir ${toString dir}")
cfg.openwakeword.customModelsDirectories)
2024-09-12 18:21:31 -04:00
# removed option https://github.com/rhasspy/wyoming-openwakeword/pull/27#issuecomment-2211822998
(optionalString
(cfg.openwakeword.package != forkedPkg)
(concatMapStringsSep " " (model: "--preload-model ${model}") cfg.openwakeword.preloadModels))
2024-09-12 18:21:31 -04:00
# removed option since preloading was removed
(optionalString
(cfg.openwakeword.package != forkedPkg)
"--trigger-level ${cfg.openwakeword.triggerLevel}")
2024-09-12 18:21:31 -04:00
"${cfg.openwakeword.extraArgs}"
]);
2024-09-01 19:19:30 -04:00
};
};
2024-09-12 18:21:31 -04:00
services.wyoming.openwakeword = mkIf (cfg.openwakeword.enable) {
package = mkOverride 900 forkedPkg;
2024-09-01 19:19:30 -04:00
};
};
}