2020-04-24 23:36:52 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.murmur;
|
|
|
|
forking = cfg.logFile != null;
|
|
|
|
configFile = pkgs.writeText "murmurd.ini" ''
|
|
|
|
database=/var/lib/murmur/murmur.sqlite
|
|
|
|
dbDriver=QSQLITE
|
|
|
|
|
|
|
|
autobanAttempts=${toString cfg.autobanAttempts}
|
|
|
|
autobanTimeframe=${toString cfg.autobanTimeframe}
|
|
|
|
autobanTime=${toString cfg.autobanTime}
|
|
|
|
|
|
|
|
logfile=${optionalString (cfg.logFile != null) cfg.logFile}
|
|
|
|
${optionalString forking "pidfile=/run/murmur/murmurd.pid"}
|
|
|
|
|
|
|
|
welcometext="${cfg.welcometext}"
|
|
|
|
port=${toString cfg.port}
|
|
|
|
|
2023-08-04 22:07:22 +00:00
|
|
|
${optionalString (cfg.hostName != "") "host=${cfg.hostName}"}
|
|
|
|
${optionalString (cfg.password != "") "serverpassword=${cfg.password}"}
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
bandwidth=${toString cfg.bandwidth}
|
|
|
|
users=${toString cfg.users}
|
|
|
|
|
|
|
|
textmessagelength=${toString cfg.textMsgLength}
|
|
|
|
imagemessagelength=${toString cfg.imgMsgLength}
|
|
|
|
allowhtml=${boolToString cfg.allowHtml}
|
|
|
|
logdays=${toString cfg.logDays}
|
|
|
|
bonjour=${boolToString cfg.bonjour}
|
|
|
|
sendversion=${boolToString cfg.sendVersion}
|
|
|
|
|
2023-08-04 22:07:22 +00:00
|
|
|
${optionalString (cfg.registerName != "") "registerName=${cfg.registerName}"}
|
|
|
|
${optionalString (cfg.registerPassword == "") "registerPassword=${cfg.registerPassword}"}
|
|
|
|
${optionalString (cfg.registerUrl != "") "registerUrl=${cfg.registerUrl}"}
|
|
|
|
${optionalString (cfg.registerHostname != "") "registerHostname=${cfg.registerHostname}"}
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
certrequired=${boolToString cfg.clientCertRequired}
|
2023-08-04 22:07:22 +00:00
|
|
|
${optionalString (cfg.sslCert != "") "sslCert=${cfg.sslCert}"}
|
|
|
|
${optionalString (cfg.sslKey != "") "sslKey=${cfg.sslKey}"}
|
|
|
|
${optionalString (cfg.sslCa != "") "sslCA=${cfg.sslCa}"}
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-08-04 22:07:22 +00:00
|
|
|
${optionalString (cfg.dbus != null) "dbus=${cfg.dbus}"}
|
2023-03-08 16:32:21 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
${cfg.extraConfig}
|
|
|
|
'';
|
|
|
|
in
|
|
|
|
{
|
|
|
|
imports = [
|
|
|
|
(mkRenamedOptionModule [ "services" "murmur" "welcome" ] [ "services" "murmur" "welcometext" ])
|
|
|
|
(mkRemovedOptionModule [ "services" "murmur" "pidfile" ] "Hardcoded to /run/murmur/murmurd.pid now")
|
|
|
|
];
|
|
|
|
|
|
|
|
options = {
|
|
|
|
services.murmur = {
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "If enabled, start the Murmur Mumble server.";
|
|
|
|
};
|
|
|
|
|
|
|
|
openFirewall = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = lib.mdDoc ''
|
|
|
|
Open ports in the firewall for the Murmur Mumble server.
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
autobanAttempts = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 10;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Number of attempts a client is allowed to make in
|
2022-08-12 12:06:08 +00:00
|
|
|
`autobanTimeframe` seconds, before being
|
|
|
|
banned for `autobanTime`.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
autobanTimeframe = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 120;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Timeframe in which a client can connect without being banned
|
|
|
|
for repeated attempts (in seconds).
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
autobanTime = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 300;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "The amount of time an IP ban lasts (in seconds).";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
logFile = mkOption {
|
|
|
|
type = types.nullOr types.path;
|
|
|
|
default = null;
|
|
|
|
example = "/var/log/murmur/murmurd.log";
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "Path to the log file for Murmur daemon. Empty means log to journald.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
welcometext = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "";
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "Welcome message for connected clients.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
port = mkOption {
|
2021-07-14 22:03:04 +00:00
|
|
|
type = types.port;
|
2020-04-24 23:36:52 +00:00
|
|
|
default = 64738;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "Ports to bind to (UDP and TCP).";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
hostName = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "";
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "Host to bind to. Defaults binding on all addresses.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
package = mkPackageOption pkgs "murmur" { };
|
2021-01-15 22:18:51 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
password = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "";
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "Required password to join server, if specified.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
bandwidth = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 72000;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Maximum bandwidth (in bits per second) that clients may send
|
|
|
|
speech at.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
users = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 100;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "Maximum number of concurrent clients allowed.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
textMsgLength = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 5000;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "Max length of text messages. Set 0 for no limit.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
imgMsgLength = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 131072;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "Max length of image messages. Set 0 for no limit.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
allowHtml = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Allow HTML in client messages, comments, and channel
|
|
|
|
descriptions.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
logDays = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 31;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
How long to store RPC logs for in the database. Set 0 to
|
|
|
|
keep logs forever, or -1 to disable DB logging.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
bonjour = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Enable Bonjour auto-discovery, which allows clients over
|
|
|
|
your LAN to automatically discover Murmur servers.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
sendVersion = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "Send Murmur version in UDP response.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
registerName = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "";
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Public server registration name, and also the name of the
|
|
|
|
Root channel. Even if you don't publicly register your
|
|
|
|
server, you probably still want to set this.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
registerPassword = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "";
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Public server registry password, used authenticate your
|
|
|
|
server to the registry to prevent impersonation; required for
|
|
|
|
subsequent registry updates.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
registerUrl = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "";
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "URL website for your server.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
registerHostname = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "";
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
DNS hostname where your server can be reached. This is only
|
|
|
|
needed if you want your server to be accessed by its
|
|
|
|
hostname and not IP - but the name *must* resolve on the
|
|
|
|
internet properly.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
clientCertRequired = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "Require clients to authenticate via certificates.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
sslCert = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "";
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "Path to your SSL certificate.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
sslKey = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "";
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "Path to your SSL key.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
sslCa = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "";
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "Path to your SSL CA certificate.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extraConfig = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "Extra configuration to put into murmur.ini.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
2020-10-11 12:50:04 +00:00
|
|
|
|
|
|
|
environmentFile = mkOption {
|
|
|
|
type = types.nullOr types.path;
|
|
|
|
default = null;
|
|
|
|
example = "/var/lib/murmur/murmurd.env";
|
2022-09-09 14:08:57 +00:00
|
|
|
description = lib.mdDoc ''
|
|
|
|
Environment file as defined in {manpage}`systemd.exec(5)`.
|
2020-10-11 12:50:04 +00:00
|
|
|
|
|
|
|
Secrets may be passed to the service without adding them to the world-readable
|
|
|
|
Nix store, by specifying placeholder variables as the option value in Nix and
|
|
|
|
setting these variables accordingly in the environment file.
|
|
|
|
|
2022-09-09 14:08:57 +00:00
|
|
|
```
|
2020-10-11 12:50:04 +00:00
|
|
|
# snippet of murmur-related config
|
|
|
|
services.murmur.password = "$MURMURD_PASSWORD";
|
2022-09-09 14:08:57 +00:00
|
|
|
```
|
2020-10-11 12:50:04 +00:00
|
|
|
|
2022-09-09 14:08:57 +00:00
|
|
|
```
|
2020-10-11 12:50:04 +00:00
|
|
|
# content of the environment file
|
|
|
|
MURMURD_PASSWORD=verysecretpassword
|
2022-09-09 14:08:57 +00:00
|
|
|
```
|
2020-10-11 12:50:04 +00:00
|
|
|
|
|
|
|
Note that this file needs to be available on the host on which
|
2022-09-09 14:08:57 +00:00
|
|
|
`murmur` is running.
|
2020-10-11 12:50:04 +00:00
|
|
|
'';
|
|
|
|
};
|
2023-03-08 16:32:21 +00:00
|
|
|
|
|
|
|
dbus = mkOption {
|
|
|
|
type = types.enum [ null "session" "system" ];
|
|
|
|
default = null;
|
|
|
|
description = lib.mdDoc "Enable D-Bus remote control. Set to the bus you want Murmur to connect to.";
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
users.users.murmur = {
|
|
|
|
description = "Murmur Service user";
|
|
|
|
home = "/var/lib/murmur";
|
|
|
|
createHome = true;
|
|
|
|
uid = config.ids.uids.murmur;
|
2020-11-03 02:18:15 +00:00
|
|
|
group = "murmur";
|
|
|
|
};
|
|
|
|
users.groups.murmur = {
|
|
|
|
gid = config.ids.gids.murmur;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2022-08-12 12:06:08 +00:00
|
|
|
networking.firewall = mkIf cfg.openFirewall {
|
|
|
|
allowedTCPPorts = [ cfg.port ];
|
|
|
|
allowedUDPPorts = [ cfg.port ];
|
|
|
|
};
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
systemd.services.murmur = {
|
|
|
|
description = "Murmur Chat Service";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
2023-07-15 17:15:38 +00:00
|
|
|
after = [ "network.target" ];
|
2020-10-11 12:50:04 +00:00
|
|
|
preStart = ''
|
|
|
|
${pkgs.envsubst}/bin/envsubst \
|
|
|
|
-o /run/murmur/murmurd.ini \
|
|
|
|
-i ${configFile}
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
# murmurd doesn't fork when logging to the console.
|
2020-10-11 12:50:04 +00:00
|
|
|
Type = if forking then "forking" else "simple";
|
|
|
|
PIDFile = mkIf forking "/run/murmur/murmurd.pid";
|
|
|
|
EnvironmentFile = mkIf (cfg.environmentFile != null) cfg.environmentFile;
|
2022-03-05 16:20:37 +00:00
|
|
|
ExecStart = "${cfg.package}/bin/mumble-server -ini /run/murmur/murmurd.ini";
|
2020-10-11 12:50:04 +00:00
|
|
|
Restart = "always";
|
|
|
|
RuntimeDirectory = "murmur";
|
|
|
|
RuntimeDirectoryMode = "0700";
|
|
|
|
User = "murmur";
|
2020-11-03 02:18:15 +00:00
|
|
|
Group = "murmur";
|
2024-02-29 20:09:43 +00:00
|
|
|
|
|
|
|
# service hardening
|
|
|
|
AmbientCapabilities = "CAP_NET_BIND_SERVICE";
|
|
|
|
CapabilityBoundingSet = "CAP_NET_BIND_SERVICE";
|
|
|
|
LockPersonality = true;
|
|
|
|
MemoryDenyWriteExecute = true;
|
|
|
|
NoNewPrivileges = true;
|
|
|
|
PrivateDevices = true;
|
|
|
|
PrivateTmp = true;
|
|
|
|
ProtectClock = true;
|
|
|
|
ProtectControlGroups = true;
|
|
|
|
ProtectHome = true;
|
|
|
|
ProtectHostname = true;
|
|
|
|
ProtectKernelLogs = true;
|
|
|
|
ProtectKernelModules = true;
|
|
|
|
ProtectKernelTunables = true;
|
|
|
|
ProtectSystem = "full";
|
|
|
|
RestrictAddressFamilies = "~AF_PACKET AF_NETLINK";
|
|
|
|
RestrictNamespaces = true;
|
|
|
|
RestrictSUIDSGID = true;
|
|
|
|
RestrictRealtime = true;
|
|
|
|
SystemCallArchitectures = "native";
|
|
|
|
SystemCallFilter = "@system-service";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
};
|
2023-03-08 16:32:21 +00:00
|
|
|
|
|
|
|
# currently not included in upstream package, addition requested at
|
|
|
|
# https://github.com/mumble-voip/mumble/issues/6078
|
|
|
|
services.dbus.packages = mkIf (cfg.dbus == "system") [(pkgs.writeTextFile {
|
|
|
|
name = "murmur-dbus-policy";
|
|
|
|
text = ''
|
|
|
|
<!DOCTYPE busconfig PUBLIC
|
|
|
|
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
|
|
|
|
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
|
|
|
|
<busconfig>
|
|
|
|
<policy user="murmur">
|
|
|
|
<allow own="net.sourceforge.mumble.murmur"/>
|
|
|
|
</policy>
|
|
|
|
|
|
|
|
<policy context="default">
|
|
|
|
<allow send_destination="net.sourceforge.mumble.murmur"/>
|
|
|
|
<allow receive_sender="net.sourceforge.mumble.murmur"/>
|
|
|
|
</policy>
|
|
|
|
</busconfig>
|
|
|
|
'';
|
|
|
|
destination = "/share/dbus-1/system.d/murmur.conf";
|
|
|
|
})];
|
2023-08-04 22:07:22 +00:00
|
|
|
|
|
|
|
security.apparmor.policies."bin.mumble-server".profile = ''
|
|
|
|
include <tunables/global>
|
|
|
|
|
|
|
|
${cfg.package}/bin/{mumble-server,.mumble-server-wrapped} {
|
|
|
|
include <abstractions/base>
|
|
|
|
include <abstractions/nameservice>
|
|
|
|
include <abstractions/ssl_certs>
|
|
|
|
include "${pkgs.apparmorRulesFromClosure { name = "mumble-server"; } cfg.package}"
|
|
|
|
pix ${cfg.package}/bin/.mumble-server-wrapped,
|
|
|
|
|
|
|
|
r ${config.environment.etc."os-release".source},
|
|
|
|
r ${config.environment.etc."lsb-release".source},
|
|
|
|
owner rwk /var/lib/murmur/murmur.sqlite,
|
|
|
|
owner rw /var/lib/murmur/murmur.sqlite-journal,
|
|
|
|
owner r /var/lib/murmur/,
|
|
|
|
r /run/murmur/murmurd.pid,
|
|
|
|
r /run/murmur/murmurd.ini,
|
|
|
|
r ${configFile},
|
|
|
|
'' + optionalString (cfg.logFile != null) ''
|
|
|
|
rw ${cfg.logFile},
|
|
|
|
'' + optionalString (cfg.sslCert != "") ''
|
|
|
|
r ${cfg.sslCert},
|
|
|
|
'' + optionalString (cfg.sslKey != "") ''
|
|
|
|
r ${cfg.sslKey},
|
|
|
|
'' + optionalString (cfg.sslCa != "") ''
|
|
|
|
r ${cfg.sslCa},
|
|
|
|
'' + optionalString (cfg.dbus != null) ''
|
|
|
|
dbus bus=${cfg.dbus}
|
|
|
|
'' + ''
|
|
|
|
}
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|