mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-11-18 22:56:00 +01:00
After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.
Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.
A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.
This commit was automatically created and can be verified using
nix-build a08b3a4d19.tar.gz \
--argstr baseRev b32a094368
result/bin/apply-formatting $NIXPKGS_PATH
186 lines
4.9 KiB
Nix
186 lines
4.9 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
|
|
let
|
|
cfg = config.services.wyoming.piper;
|
|
|
|
inherit (lib)
|
|
escapeShellArgs
|
|
mkOption
|
|
mkEnableOption
|
|
mkPackageOption
|
|
types
|
|
;
|
|
|
|
inherit (builtins)
|
|
toString
|
|
;
|
|
|
|
in
|
|
|
|
{
|
|
meta.buildDocsInSandbox = false;
|
|
|
|
options.services.wyoming.piper = with types; {
|
|
package = mkPackageOption pkgs "wyoming-piper" { };
|
|
|
|
servers = mkOption {
|
|
default = { };
|
|
description = ''
|
|
Attribute set of piper instances to spawn.
|
|
'';
|
|
type = types.attrsOf (
|
|
types.submodule (
|
|
{ ... }:
|
|
{
|
|
options = {
|
|
enable = mkEnableOption "Wyoming Piper server";
|
|
|
|
piper = mkPackageOption pkgs "piper-tts" { };
|
|
|
|
voice = mkOption {
|
|
type = str;
|
|
example = "en-us-ryan-medium";
|
|
description = ''
|
|
Name of the voice model to use. See the following website for samples:
|
|
https://rhasspy.github.io/piper-samples/
|
|
'';
|
|
};
|
|
|
|
uri = mkOption {
|
|
type = strMatching "^(tcp|unix)://.*$";
|
|
example = "tcp://0.0.0.0:10200";
|
|
description = ''
|
|
URI to bind the wyoming server to.
|
|
'';
|
|
};
|
|
|
|
speaker = mkOption {
|
|
type = ints.unsigned;
|
|
default = 0;
|
|
description = ''
|
|
ID of a specific speaker in a multi-speaker model.
|
|
'';
|
|
apply = toString;
|
|
};
|
|
|
|
noiseScale = mkOption {
|
|
type = float;
|
|
default = 0.667;
|
|
description = ''
|
|
Generator noise value.
|
|
'';
|
|
apply = toString;
|
|
};
|
|
|
|
noiseWidth = mkOption {
|
|
type = float;
|
|
default = 0.333;
|
|
description = ''
|
|
Phoneme width noise value.
|
|
'';
|
|
apply = toString;
|
|
};
|
|
|
|
lengthScale = mkOption {
|
|
type = float;
|
|
default = 1.0;
|
|
description = ''
|
|
Phoneme length value.
|
|
'';
|
|
apply = toString;
|
|
};
|
|
|
|
extraArgs = mkOption {
|
|
type = listOf str;
|
|
default = [ ];
|
|
description = ''
|
|
Extra arguments to pass to the server commandline.
|
|
'';
|
|
apply = escapeShellArgs;
|
|
};
|
|
};
|
|
}
|
|
)
|
|
);
|
|
};
|
|
};
|
|
|
|
config =
|
|
let
|
|
inherit (lib)
|
|
mapAttrs'
|
|
mkIf
|
|
nameValuePair
|
|
;
|
|
in
|
|
mkIf (cfg.servers != { }) {
|
|
systemd.services = mapAttrs' (
|
|
server: options:
|
|
nameValuePair "wyoming-piper-${server}" {
|
|
inherit (options) enable;
|
|
description = "Wyoming Piper server instance ${server}";
|
|
wants = [
|
|
"network-online.target"
|
|
];
|
|
after = [
|
|
"network-online.target"
|
|
];
|
|
wantedBy = [
|
|
"multi-user.target"
|
|
];
|
|
serviceConfig = {
|
|
DynamicUser = true;
|
|
User = "wyoming-piper";
|
|
StateDirectory = "wyoming/piper";
|
|
# https://github.com/home-assistant/addons/blob/master/piper/rootfs/etc/s6-overlay/s6-rc.d/piper/run
|
|
ExecStart = ''
|
|
${cfg.package}/bin/wyoming-piper \
|
|
--data-dir $STATE_DIRECTORY \
|
|
--download-dir $STATE_DIRECTORY \
|
|
--uri ${options.uri} \
|
|
--piper ${options.piper}/bin/piper \
|
|
--voice ${options.voice} \
|
|
--speaker ${options.speaker} \
|
|
--length-scale ${options.lengthScale} \
|
|
--noise-scale ${options.noiseScale} \
|
|
--noise-w ${options.noiseWidth} ${options.extraArgs}
|
|
'';
|
|
CapabilityBoundingSet = "";
|
|
DeviceAllow = "";
|
|
DevicePolicy = "closed";
|
|
LockPersonality = true;
|
|
MemoryDenyWriteExecute = true;
|
|
PrivateDevices = true;
|
|
PrivateUsers = true;
|
|
ProtectHome = true;
|
|
ProtectHostname = true;
|
|
ProtectKernelLogs = true;
|
|
ProtectKernelModules = true;
|
|
ProtectKernelTunables = true;
|
|
ProtectControlGroups = true;
|
|
ProtectProc = "invisible";
|
|
ProcSubset = "pid";
|
|
RestrictAddressFamilies = [
|
|
"AF_INET"
|
|
"AF_INET6"
|
|
"AF_UNIX"
|
|
];
|
|
RestrictNamespaces = true;
|
|
RestrictRealtime = true;
|
|
SystemCallArchitectures = "native";
|
|
SystemCallFilter = [
|
|
"@system-service"
|
|
"~@privileged"
|
|
];
|
|
UMask = "0077";
|
|
};
|
|
}
|
|
) cfg.servers;
|
|
};
|
|
}
|