2014-04-14 14:26:48 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
2014-04-01 04:31:09 +00:00
|
|
|
|
2014-04-14 14:26:48 +00:00
|
|
|
with lib;
|
2014-04-01 04:31:09 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.murmur;
|
2018-04-11 14:41:42 +00:00
|
|
|
forking = cfg.logFile != null;
|
2014-04-01 04:31:09 +00:00
|
|
|
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}
|
|
|
|
|
2018-04-11 14:41:42 +00:00
|
|
|
logfile=${optionalString (cfg.logFile != null) cfg.logFile}
|
|
|
|
${optionalString forking "pidfile=/run/murmur/murmurd.pid"}
|
2014-04-01 04:31:09 +00:00
|
|
|
|
2016-09-13 23:24:25 +00:00
|
|
|
welcometext="${cfg.welcometext}"
|
2014-04-01 04:31:09 +00:00
|
|
|
port=${toString cfg.port}
|
|
|
|
|
|
|
|
${if cfg.hostName == "" then "" else "host="+cfg.hostName}
|
|
|
|
${if cfg.password == "" then "" else "serverpassword="+cfg.password}
|
|
|
|
|
|
|
|
bandwidth=${toString cfg.bandwidth}
|
|
|
|
users=${toString cfg.users}
|
|
|
|
|
|
|
|
textmessagelength=${toString cfg.textMsgLength}
|
|
|
|
imagemessagelength=${toString cfg.imgMsgLength}
|
2017-04-11 16:08:51 +00:00
|
|
|
allowhtml=${boolToString cfg.allowHtml}
|
2014-04-01 04:31:09 +00:00
|
|
|
logdays=${toString cfg.logDays}
|
2017-04-14 09:05:42 +00:00
|
|
|
bonjour=${boolToString cfg.bonjour}
|
|
|
|
sendversion=${boolToString cfg.sendVersion}
|
2014-04-01 04:31:09 +00:00
|
|
|
|
|
|
|
${if cfg.registerName == "" then "" else "registerName="+cfg.registerName}
|
|
|
|
${if cfg.registerPassword == "" then "" else "registerPassword="+cfg.registerPassword}
|
|
|
|
${if cfg.registerUrl == "" then "" else "registerUrl="+cfg.registerUrl}
|
|
|
|
${if cfg.registerHostname == "" then "" else "registerHostname="+cfg.registerHostname}
|
|
|
|
|
2017-04-14 09:05:42 +00:00
|
|
|
certrequired=${boolToString cfg.clientCertRequired}
|
2014-04-01 04:31:09 +00:00
|
|
|
${if cfg.sslCert == "" then "" else "sslCert="+cfg.sslCert}
|
|
|
|
${if cfg.sslKey == "" then "" else "sslKey="+cfg.sslKey}
|
2015-12-03 01:36:19 +00:00
|
|
|
${if cfg.sslCa == "" then "" else "sslCA="+cfg.sslCa}
|
2017-04-11 16:08:51 +00:00
|
|
|
|
2015-12-03 01:36:19 +00:00
|
|
|
${cfg.extraConfig}
|
2014-04-01 04:31:09 +00:00
|
|
|
'';
|
|
|
|
in
|
|
|
|
{
|
2019-12-10 01:51:19 +00:00
|
|
|
imports = [
|
|
|
|
(mkRenamedOptionModule [ "services" "murmur" "welcome" ] [ "services" "murmur" "welcometext" ])
|
|
|
|
(mkRemovedOptionModule [ "services" "murmur" "pidfile" ] "Hardcoded to /run/murmur/murmurd.pid now")
|
|
|
|
];
|
|
|
|
|
2014-04-01 04:31:09 +00:00
|
|
|
options = {
|
|
|
|
services.murmur = {
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2018-10-08 09:52:55 +00:00
|
|
|
description = "If enabled, start the Murmur Mumble server.";
|
2014-04-01 04:31:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
autobanAttempts = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 10;
|
|
|
|
description = ''
|
|
|
|
Number of attempts a client is allowed to make in
|
|
|
|
<literal>autobanTimeframe</literal> seconds, before being
|
|
|
|
banned for <literal>autobanTime</literal>.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
autobanTimeframe = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 120;
|
|
|
|
description = ''
|
|
|
|
Timeframe in which a client can connect without being banned
|
|
|
|
for repeated attempts (in seconds).
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
autobanTime = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 300;
|
|
|
|
description = "The amount of time an IP ban lasts (in seconds).";
|
|
|
|
};
|
|
|
|
|
2018-04-11 14:41:42 +00:00
|
|
|
logFile = mkOption {
|
|
|
|
type = types.nullOr types.path;
|
|
|
|
default = null;
|
|
|
|
example = "/var/log/murmur/murmurd.log";
|
|
|
|
description = "Path to the log file for Murmur daemon. Empty means log to journald.";
|
2014-04-01 04:31:09 +00:00
|
|
|
};
|
|
|
|
|
2016-09-13 23:24:25 +00:00
|
|
|
welcometext = mkOption {
|
2014-04-01 04:31:09 +00:00
|
|
|
type = types.str;
|
|
|
|
default = "";
|
|
|
|
description = "Welcome message for connected clients.";
|
|
|
|
};
|
|
|
|
|
|
|
|
port = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 64738;
|
|
|
|
description = "Ports to bind to (UDP and TCP).";
|
|
|
|
};
|
|
|
|
|
|
|
|
hostName = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "";
|
|
|
|
description = "Host to bind to. Defaults binding on all addresses.";
|
|
|
|
};
|
|
|
|
|
2021-01-10 16:50:20 +00:00
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.murmur;
|
|
|
|
defaultText = "pkgs.murmur";
|
|
|
|
description = "Overridable attribute of the murmur package to use.";
|
|
|
|
};
|
|
|
|
|
2014-04-01 04:31:09 +00:00
|
|
|
password = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "";
|
|
|
|
description = "Required password to join server, if specified.";
|
|
|
|
};
|
|
|
|
|
|
|
|
bandwidth = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 72000;
|
|
|
|
description = ''
|
|
|
|
Maximum bandwidth (in bits per second) that clients may send
|
|
|
|
speech at.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
users = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 100;
|
|
|
|
description = "Maximum number of concurrent clients allowed.";
|
|
|
|
};
|
|
|
|
|
|
|
|
textMsgLength = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 5000;
|
|
|
|
description = "Max length of text messages. Set 0 for no limit.";
|
|
|
|
};
|
|
|
|
|
|
|
|
imgMsgLength = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 131072;
|
|
|
|
description = "Max length of image messages. Set 0 for no limit.";
|
|
|
|
};
|
|
|
|
|
|
|
|
allowHtml = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
|
|
|
description = ''
|
|
|
|
Allow HTML in client messages, comments, and channel
|
|
|
|
descriptions.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
logDays = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 31;
|
|
|
|
description = ''
|
|
|
|
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;
|
|
|
|
description = ''
|
|
|
|
Enable Bonjour auto-discovery, which allows clients over
|
|
|
|
your LAN to automatically discover Murmur servers.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
sendVersion = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
|
|
|
description = "Send Murmur version in UDP response.";
|
|
|
|
};
|
|
|
|
|
|
|
|
registerName = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "";
|
|
|
|
description = ''
|
|
|
|
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 = "";
|
|
|
|
description = ''
|
|
|
|
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 = "";
|
|
|
|
description = "URL website for your server.";
|
|
|
|
};
|
|
|
|
|
|
|
|
registerHostname = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "";
|
|
|
|
description = ''
|
|
|
|
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;
|
|
|
|
description = "Require clients to authenticate via certificates.";
|
|
|
|
};
|
|
|
|
|
|
|
|
sslCert = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "";
|
|
|
|
description = "Path to your SSL certificate.";
|
|
|
|
};
|
|
|
|
|
|
|
|
sslKey = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "";
|
|
|
|
description = "Path to your SSL key.";
|
|
|
|
};
|
2015-12-03 01:36:19 +00:00
|
|
|
|
|
|
|
sslCa = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "";
|
|
|
|
description = "Path to your SSL CA certificate.";
|
|
|
|
};
|
|
|
|
|
|
|
|
extraConfig = mkOption {
|
2016-10-23 17:33:41 +00:00
|
|
|
type = types.lines;
|
2015-12-03 01:36:19 +00:00
|
|
|
default = "";
|
2019-09-06 17:29:16 +00:00
|
|
|
description = "Extra configuration to put into murmur.ini.";
|
2015-12-03 01:36:19 +00:00
|
|
|
};
|
2020-10-07 09:27:05 +00:00
|
|
|
|
|
|
|
environmentFile = mkOption {
|
|
|
|
type = types.nullOr types.path;
|
|
|
|
default = null;
|
|
|
|
example = "/var/lib/murmur/murmurd.env";
|
|
|
|
description = ''
|
|
|
|
Environment file as defined in <citerefentry>
|
|
|
|
<refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum>
|
|
|
|
</citerefentry>.
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
<programlisting>
|
|
|
|
# snippet of murmur-related config
|
|
|
|
services.murmur.password = "$MURMURD_PASSWORD";
|
|
|
|
</programlisting>
|
|
|
|
|
|
|
|
<programlisting>
|
|
|
|
# content of the environment file
|
|
|
|
MURMURD_PASSWORD=verysecretpassword
|
|
|
|
</programlisting>
|
|
|
|
|
|
|
|
Note that this file needs to be available on the host on which
|
|
|
|
<literal>murmur</literal> is running.
|
|
|
|
'';
|
|
|
|
};
|
2014-04-01 04:31:09 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2018-06-29 23:58:35 +00:00
|
|
|
users.users.murmur = {
|
2014-04-01 04:31:09 +00:00
|
|
|
description = "Murmur Service user";
|
|
|
|
home = "/var/lib/murmur";
|
|
|
|
createHome = true;
|
|
|
|
uid = config.ids.uids.murmur;
|
2020-10-29 09:32:04 +00:00
|
|
|
group = "murmur";
|
|
|
|
};
|
|
|
|
users.groups.murmur = {
|
|
|
|
gid = config.ids.gids.murmur;
|
2014-04-01 04:31:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.murmur = {
|
|
|
|
description = "Murmur Chat Service";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
2018-07-02 03:30:43 +00:00
|
|
|
after = [ "network-online.target "];
|
2020-10-07 09:27:05 +00:00
|
|
|
preStart = ''
|
|
|
|
${pkgs.envsubst}/bin/envsubst \
|
|
|
|
-o /run/murmur/murmurd.ini \
|
|
|
|
-i ${configFile}
|
|
|
|
'';
|
2014-04-01 04:31:09 +00:00
|
|
|
|
|
|
|
serviceConfig = {
|
2018-04-11 14:41:42 +00:00
|
|
|
# murmurd doesn't fork when logging to the console.
|
2020-10-07 09:27:05 +00:00
|
|
|
Type = if forking then "forking" else "simple";
|
|
|
|
PIDFile = mkIf forking "/run/murmur/murmurd.pid";
|
|
|
|
EnvironmentFile = mkIf (cfg.environmentFile != null) cfg.environmentFile;
|
2021-01-10 16:50:20 +00:00
|
|
|
ExecStart = "${cfg.package}/bin/murmurd -ini /run/murmur/murmurd.ini";
|
2020-10-07 09:27:05 +00:00
|
|
|
Restart = "always";
|
|
|
|
RuntimeDirectory = "murmur";
|
|
|
|
RuntimeDirectoryMode = "0700";
|
|
|
|
User = "murmur";
|
2020-10-29 09:32:04 +00:00
|
|
|
Group = "murmur";
|
2014-04-01 04:31:09 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|