nixos-configs/nixosModules/wyoming-plus/default.nix
matt1432 c75cb0759d
All checks were successful
Discord / discord commits (push) Has been skipped
refactor(wyoming): move to tflite dep instead of tensorflow
2024-12-15 17:14:49 -05:00

49 lines
1.6 KiB
Nix

{
config,
lib,
pkgs,
...
}: let
inherit (lib.modules) mkForce mkIf mkOverride;
inherit (lib.strings) concatMapStringsSep concatStringsSep optionalString;
cfg = config.services.wyoming;
in {
config = let
forkedPkg = (import ./pkgs {inherit pkgs;}).wyoming-openwakeword;
in {
systemd.services = mkIf (cfg.openwakeword.enable) {
wyoming-openwakeword.serviceConfig = {
MemoryDenyWriteExecute = mkForce (cfg.openwakeword.package != forkedPkg);
# changes according to https://github.com/rhasspy/wyoming-openwakeword/pull/27
ExecStart = mkForce (concatStringsSep " " [
"${cfg.openwakeword.package}/bin/wyoming-openwakeword"
"--uri ${cfg.openwakeword.uri}"
"--threshold ${cfg.openwakeword.threshold}"
(concatMapStringsSep " "
(dir: "--custom-model-dir ${toString dir}")
cfg.openwakeword.customModelsDirectories)
# 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))
# removed option since preloading was removed
(optionalString
(cfg.openwakeword.package != forkedPkg)
"--trigger-level ${cfg.openwakeword.triggerLevel}")
"${cfg.openwakeword.extraArgs}"
]);
};
};
services.wyoming.openwakeword = mkIf (cfg.openwakeword.enable) {
package = mkOverride 900 forkedPkg;
};
};
}