2024-09-05 08:48:42 -04:00
|
|
|
{
|
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;
|
2024-10-10 13:11:11 -04:00
|
|
|
inherit (lib.modules) mkForce mkIf mkOverride;
|
2025-01-19 00:45:29 -05:00
|
|
|
inherit (lib.strings) concatMapStringsSep concatStringsSep escapeShellArgs;
|
2024-09-01 19:19:30 -04:00
|
|
|
|
2024-09-12 18:21:31 -04:00
|
|
|
cfg = config.services.wyoming;
|
2025-01-04 19:02:30 -05:00
|
|
|
|
|
|
|
forkedPkg = pkgs.callPackage ./pkgs {};
|
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;
|
|
|
|
};
|
|
|
|
|
2025-01-04 19:02:30 -05:00
|
|
|
config = {
|
2024-12-15 10:45:06 -05:00
|
|
|
systemd.services = mkIf (cfg.openwakeword.enable) {
|
2025-01-19 00:45:29 -05:00
|
|
|
# For some reason I can't just override `ExecStart` anymore.
|
|
|
|
wyoming-openwakeword.serviceConfig = mkForce {
|
|
|
|
DynamicUser = true;
|
|
|
|
User = "wyoming-openwakeword";
|
|
|
|
|
|
|
|
MemoryDenyWriteExecute = cfg.openwakeword.package != forkedPkg;
|
2024-09-12 18:21:31 -04:00
|
|
|
|
2024-12-15 10:45:06 -05:00
|
|
|
# changes according to https://github.com/rhasspy/wyoming-openwakeword/pull/27
|
2025-01-19 00:45:29 -05:00
|
|
|
ExecStart = concatStringsSep " " [
|
2024-12-20 02:29:24 -05:00
|
|
|
(getExe cfg.openwakeword.package)
|
2024-09-12 18:21:31 -04:00
|
|
|
|
2024-12-15 10:45:06 -05: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
|
|
|
|
2024-12-15 10:45:06 -05: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
|
|
|
|
2025-01-19 00:45:29 -05:00
|
|
|
(escapeShellArgs cfg.openwakeword.extraArgs)
|
|
|
|
];
|
|
|
|
|
|
|
|
CapabilityBoundingSet = "";
|
|
|
|
DeviceAllow = "";
|
|
|
|
DevicePolicy = "closed";
|
|
|
|
LockPersonality = true;
|
|
|
|
PrivateDevices = true;
|
|
|
|
PrivateUsers = true;
|
|
|
|
ProtectHome = true;
|
|
|
|
ProtectHostname = true;
|
|
|
|
ProtectKernelLogs = true;
|
|
|
|
ProtectKernelModules = true;
|
|
|
|
ProtectKernelTunables = true;
|
|
|
|
ProtectControlGroups = true;
|
|
|
|
ProtectProc = "invisible";
|
|
|
|
ProcSubset = "all"; # reads /proc/cpuinfo
|
|
|
|
RestrictAddressFamilies = [
|
|
|
|
"AF_INET"
|
|
|
|
"AF_INET6"
|
|
|
|
"AF_UNIX"
|
|
|
|
];
|
|
|
|
RestrictNamespaces = true;
|
|
|
|
RestrictRealtime = true;
|
|
|
|
RuntimeDirectory = "wyoming-openwakeword";
|
|
|
|
SystemCallArchitectures = "native";
|
|
|
|
SystemCallFilter = [
|
|
|
|
"@system-service"
|
|
|
|
"~@privileged"
|
|
|
|
];
|
|
|
|
UMask = "0077";
|
2024-09-01 19:19:30 -04:00
|
|
|
};
|
2024-12-15 10:45:06 -05: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
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|