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

53 lines
1.4 KiB
Nix
Raw Permalink Normal View History

{
2024-09-01 19:19:30 -04:00
config,
lib,
pkgs,
...
}: let
2024-12-20 02:29:24 -05:00
inherit (lib) getExe mkOption types;
inherit (lib.modules) mkForce mkIf mkOverride;
2024-12-20 02:29:24 -05:00
inherit (lib.strings) concatMapStringsSep concatStringsSep;
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-12-20 02:29:24 -05:00
options.services.wyoming.openwakeword.vadThreshold = mkOption {
type = types.float;
default = 0.0;
apply = toString;
};
2024-09-12 18:21:31 -04:00
config = let
2024-12-20 02:29:24 -05:00
forkedPkg = pkgs.callPackage ./pkgs {};
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 " " [
2024-12-20 02:29:24 -05:00
(getExe cfg.openwakeword.package)
2024-09-12 18:21:31 -04:00
"--uri ${cfg.openwakeword.uri}"
"--threshold ${cfg.openwakeword.threshold}"
2024-12-20 02:29:24 -05:00
"--vad-threshold ${cfg.openwakeword.vadThreshold}"
"--trigger-level ${cfg.openwakeword.triggerLevel}"
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
2024-12-20 02:29:24 -05:00
(concatMapStringsSep " "
(model: "--preload-model ${model}")
cfg.openwakeword.preloadModels)
2024-09-12 18:21:31 -04:00
2024-12-20 02:29:24 -05: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
};
};
}