1 { config, lib, pkgs, ... }:
6 cfg = config.services.murmur;
7 forking = cfg.logFile != null;
8 configFile = pkgs.writeText "murmurd.ini" ''
9 database=/var/lib/murmur/murmur.sqlite
12 autobanAttempts=${toString cfg.autobanAttempts}
13 autobanTimeframe=${toString cfg.autobanTimeframe}
14 autobanTime=${toString cfg.autobanTime}
16 logfile=${optionalString (cfg.logFile != null) cfg.logFile}
17 ${optionalString forking "pidfile=/run/murmur/murmurd.pid"}
19 welcometext="${cfg.welcometext}"
20 port=${toString cfg.port}
22 ${if cfg.hostName == "" then "" else "host="+cfg.hostName}
23 ${if cfg.password == "" then "" else "serverpassword="+cfg.password}
25 bandwidth=${toString cfg.bandwidth}
26 users=${toString cfg.users}
28 textmessagelength=${toString cfg.textMsgLength}
29 imagemessagelength=${toString cfg.imgMsgLength}
30 allowhtml=${boolToString cfg.allowHtml}
31 logdays=${toString cfg.logDays}
32 bonjour=${boolToString cfg.bonjour}
33 sendversion=${boolToString cfg.sendVersion}
35 ${if cfg.registerName == "" then "" else "registerName="+cfg.registerName}
36 ${if cfg.registerPassword == "" then "" else "registerPassword="+cfg.registerPassword}
37 ${if cfg.registerUrl == "" then "" else "registerUrl="+cfg.registerUrl}
38 ${if cfg.registerHostname == "" then "" else "registerHostname="+cfg.registerHostname}
40 certrequired=${boolToString cfg.clientCertRequired}
41 ${if cfg.sslCert == "" then "" else "sslCert="+cfg.sslCert}
42 ${if cfg.sslKey == "" then "" else "sslKey="+cfg.sslKey}
43 ${if cfg.sslCa == "" then "" else "sslCA="+cfg.sslCa}
50 (mkRenamedOptionModule [ "services" "murmur" "welcome" ] [ "services" "murmur" "welcometext" ])
51 (mkRemovedOptionModule [ "services" "murmur" "pidfile" ] "Hardcoded to /run/murmur/murmurd.pid now")
59 description = lib.mdDoc "If enabled, start the Murmur Mumble server.";
62 openFirewall = mkOption {
65 description = lib.mdDoc ''
66 Open ports in the firewall for the Murmur Mumble server.
70 autobanAttempts = mkOption {
73 description = lib.mdDoc ''
74 Number of attempts a client is allowed to make in
75 `autobanTimeframe` seconds, before being
76 banned for `autobanTime`.
80 autobanTimeframe = mkOption {
83 description = lib.mdDoc ''
84 Timeframe in which a client can connect without being banned
85 for repeated attempts (in seconds).
89 autobanTime = mkOption {
92 description = lib.mdDoc "The amount of time an IP ban lasts (in seconds).";
96 type = types.nullOr types.path;
98 example = "/var/log/murmur/murmurd.log";
99 description = lib.mdDoc "Path to the log file for Murmur daemon. Empty means log to journald.";
102 welcometext = mkOption {
105 description = lib.mdDoc "Welcome message for connected clients.";
111 description = lib.mdDoc "Ports to bind to (UDP and TCP).";
114 hostName = mkOption {
117 description = lib.mdDoc "Host to bind to. Defaults binding on all addresses.";
121 type = types.package;
122 default = pkgs.murmur;
123 defaultText = literalExpression "pkgs.murmur";
124 description = lib.mdDoc "Overridable attribute of the murmur package to use.";
127 password = mkOption {
130 description = lib.mdDoc "Required password to join server, if specified.";
133 bandwidth = mkOption {
136 description = lib.mdDoc ''
137 Maximum bandwidth (in bits per second) that clients may send
145 description = lib.mdDoc "Maximum number of concurrent clients allowed.";
148 textMsgLength = mkOption {
151 description = lib.mdDoc "Max length of text messages. Set 0 for no limit.";
154 imgMsgLength = mkOption {
157 description = lib.mdDoc "Max length of image messages. Set 0 for no limit.";
160 allowHtml = mkOption {
163 description = lib.mdDoc ''
164 Allow HTML in client messages, comments, and channel
172 description = lib.mdDoc ''
173 How long to store RPC logs for in the database. Set 0 to
174 keep logs forever, or -1 to disable DB logging.
181 description = lib.mdDoc ''
182 Enable Bonjour auto-discovery, which allows clients over
183 your LAN to automatically discover Murmur servers.
187 sendVersion = mkOption {
190 description = lib.mdDoc "Send Murmur version in UDP response.";
193 registerName = mkOption {
196 description = lib.mdDoc ''
197 Public server registration name, and also the name of the
198 Root channel. Even if you don't publicly register your
199 server, you probably still want to set this.
203 registerPassword = mkOption {
206 description = lib.mdDoc ''
207 Public server registry password, used authenticate your
208 server to the registry to prevent impersonation; required for
209 subsequent registry updates.
213 registerUrl = mkOption {
216 description = lib.mdDoc "URL website for your server.";
219 registerHostname = mkOption {
222 description = lib.mdDoc ''
223 DNS hostname where your server can be reached. This is only
224 needed if you want your server to be accessed by its
225 hostname and not IP - but the name *must* resolve on the
230 clientCertRequired = mkOption {
233 description = lib.mdDoc "Require clients to authenticate via certificates.";
239 description = lib.mdDoc "Path to your SSL certificate.";
245 description = lib.mdDoc "Path to your SSL key.";
251 description = lib.mdDoc "Path to your SSL CA certificate.";
254 extraConfig = mkOption {
257 description = lib.mdDoc "Extra configuration to put into murmur.ini.";
260 environmentFile = mkOption {
261 type = types.nullOr types.path;
263 example = "/var/lib/murmur/murmurd.env";
264 description = lib.mdDoc ''
265 Environment file as defined in {manpage}`systemd.exec(5)`.
267 Secrets may be passed to the service without adding them to the world-readable
268 Nix store, by specifying placeholder variables as the option value in Nix and
269 setting these variables accordingly in the environment file.
272 # snippet of murmur-related config
273 services.murmur.password = "$MURMURD_PASSWORD";
277 # content of the environment file
278 MURMURD_PASSWORD=verysecretpassword
281 Note that this file needs to be available on the host on which
288 config = mkIf cfg.enable {
289 users.users.murmur = {
290 description = "Murmur Service user";
291 home = "/var/lib/murmur";
293 uid = config.ids.uids.murmur;
296 users.groups.murmur = {
297 gid = config.ids.gids.murmur;
300 networking.firewall = mkIf cfg.openFirewall {
301 allowedTCPPorts = [ cfg.port ];
302 allowedUDPPorts = [ cfg.port ];
305 systemd.services.murmur = {
306 description = "Murmur Chat Service";
307 wantedBy = [ "multi-user.target" ];
308 after = [ "network-online.target" ];
310 ${pkgs.envsubst}/bin/envsubst \
311 -o /run/murmur/murmurd.ini \
316 # murmurd doesn't fork when logging to the console.
317 Type = if forking then "forking" else "simple";
318 PIDFile = mkIf forking "/run/murmur/murmurd.pid";
319 EnvironmentFile = mkIf (cfg.environmentFile != null) cfg.environmentFile;
320 ExecStart = "${cfg.package}/bin/mumble-server -ini /run/murmur/murmurd.ini";
322 RuntimeDirectory = "murmur";
323 RuntimeDirectoryMode = "0700";