summary refs log tree commit diff
diff options
context:
space:
mode:
authorNikolay Amiantov <ab@fmap.me>2018-04-11 17:41:42 +0300
committerNikolay Amiantov <ab@fmap.me>2019-05-30 15:43:32 +0300
commitf23c110692c66a278c1ffcd57d880b5ed0803b06 (patch)
tree15a5fee50f19be142668341ce94a610c411d8211
parentecb99304ff365a23ea82f832679becde06d1e5f6 (diff)
downloadnixpkgs-f23c110692c66a278c1ffcd57d880b5ed0803b06.tar
nixpkgs-f23c110692c66a278c1ffcd57d880b5ed0803b06.tar.gz
nixpkgs-f23c110692c66a278c1ffcd57d880b5ed0803b06.tar.bz2
nixpkgs-f23c110692c66a278c1ffcd57d880b5ed0803b06.tar.lz
nixpkgs-f23c110692c66a278c1ffcd57d880b5ed0803b06.tar.xz
nixpkgs-f23c110692c66a278c1ffcd57d880b5ed0803b06.tar.zst
nixpkgs-f23c110692c66a278c1ffcd57d880b5ed0803b06.zip
murmur service: log to journald by default
Save an option to log to file with new `logFile` option.

As a side effect deprecate `pidfile` option and instead use systemd's
RuntimeDirectory.
-rw-r--r--nixos/modules/rename.nix3
-rw-r--r--nixos/modules/services/networking/murmur.nix28
2 files changed, 14 insertions, 17 deletions
diff --git a/nixos/modules/rename.nix b/nixos/modules/rename.nix
index b2c030fb779..7db0f7f050a 100644
--- a/nixos/modules/rename.nix
+++ b/nixos/modules/rename.nix
@@ -113,9 +113,10 @@ with lib;
 
     # murmur
     (mkRenamedOptionModule [ "services" "murmur" "welcome" ] [ "services" "murmur" "welcometext" ])
+    (mkRemovedOptionModule [ "services" "murmur" "pidfile" ] "Hardcoded to /run/murmur/murmurd.pid now")
 
     # parsoid
-    (mkRemovedOptionModule [ "services" "parsoid" "interwikis" ] [ "services" "parsoid" "wikis" ])
+    (mkRemovedOptionModule [ "services" "parsoid" "interwikis" ] "Use services.parsoid.wikis instead")
 
     # plexpy / tautulli
     (mkRenamedOptionModule [ "services" "plexpy" ] [ "services" "tautulli" ])
diff --git a/nixos/modules/services/networking/murmur.nix b/nixos/modules/services/networking/murmur.nix
index a6e90feff7e..7ac4d0c6419 100644
--- a/nixos/modules/services/networking/murmur.nix
+++ b/nixos/modules/services/networking/murmur.nix
@@ -4,6 +4,7 @@ with lib;
 
 let
   cfg = config.services.murmur;
+  forking = cfg.logFile != null;
   configFile = pkgs.writeText "murmurd.ini" ''
     database=/var/lib/murmur/murmur.sqlite
     dbDriver=QSQLITE
@@ -12,8 +13,8 @@ let
     autobanTimeframe=${toString cfg.autobanTimeframe}
     autobanTime=${toString cfg.autobanTime}
 
-    logfile=/var/log/murmur/murmurd.log
-    pidfile=${cfg.pidfile}
+    logfile=${optionalString (cfg.logFile != null) cfg.logFile}
+    ${optionalString forking "pidfile=/run/murmur/murmurd.pid"}
 
     welcometext="${cfg.welcometext}"
     port=${toString cfg.port}
@@ -78,10 +79,11 @@ in
         description = "The amount of time an IP ban lasts (in seconds).";
       };
 
-      pidfile = mkOption {
-        type = types.path;
-        default = "/run/murmur/murmurd.pid";
-        description = "Path to PID file for Murmur daemon.";
+      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.";
       };
 
       welcometext = mkOption {
@@ -251,19 +253,13 @@ in
       after       = [ "network-online.target "];
 
       serviceConfig = {
-        Type      = "forking";
-        RuntimeDirectory = "murmur";
-        PIDFile   = cfg.pidfile;
-        Restart   = "always";
+        # murmurd doesn't fork when logging to the console.
+        Type      = if forking then "forking" else "simple";
+        PIDFile   = mkIf forking "/run/murmur/murmurd.pid";
+        RuntimeDirectory = mkIf forking "murmur";
         User      = "murmur";
         ExecStart = "${pkgs.murmur}/bin/murmurd -ini ${configFile}";
-        PermissionsStartOnly = true;
       };
-
-      preStart = ''
-        mkdir -p /var/log/murmur
-        chown -R murmur /var/log/murmur
-      '';
     };
   };
 }