Commit f6d9a910 authored by Felix Singer's avatar Felix Singer
Browse files

nixos/murmur: Hard-code log directory to /var/log/murmur



The Murmur NixOS module allows logging to a file instead of journald. At
the moment any arbitrary directory may be specified by using the
`logfile` option, but nothing ensures that the directory exists or
proper permissions are configured.

Since there is not much reason to specify a custom directory for log
files anyway, just use `/var/log/murmur` by using the systemd way. This
replaces the option `logfile` with the boolean option `logToFile` as
well.

Signed-off-by: default avatarFelix Singer <felixsinger@posteo.net>
parent e3fcac5e
Loading
Loading
Loading
Loading
+16 −10
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@

let
  cfg = config.services.murmur;
  forking = cfg.logFile != null;
  forking = cfg.logToFile;
  configFile = pkgs.writeText "murmurd.ini" ''
    database=${cfg.stateDir}/murmur.sqlite
    dbDriver=QSQLITE
@@ -16,7 +16,7 @@ let
    autobanTimeframe=${toString cfg.autobanTimeframe}
    autobanTime=${toString cfg.autobanTime}

    logfile=${lib.optionalString (cfg.logFile != null) cfg.logFile}
    logfile=${lib.optionalString cfg.logToFile "/var/log/murmur/murmurd.log"}
    ${lib.optionalString forking "pidfile=/run/murmur/murmurd.pid"}

    welcometext="${cfg.welcometext}"
@@ -51,6 +51,15 @@ let
  '';
in
{

  imports = [
    (lib.mkRemovedOptionModule [
      "services"
      "murmur"
      "logfile"
    ] "This option has been superseded by services.murmur.logToFile")
  ];

  options = {
    services.murmur = {
      enable = lib.mkEnableOption "Mumble server";
@@ -108,12 +117,7 @@ in
        description = "The amount of time an IP ban lasts (in seconds).";
      };

      logFile = lib.mkOption {
        type = lib.types.nullOr lib.types.path;
        default = null;
        example = "/var/log/murmur/murmurd.log";
        description = "Path to the log file for Murmur daemon. Empty means log to journald.";
      };
      logToFile = lib.mkEnableOption "logging to a file instead of journald, which is stored in /var/log/murmur";

      welcometext = lib.mkOption {
        type = lib.types.str;
@@ -329,6 +333,8 @@ in
        EnvironmentFile = lib.mkIf (cfg.environmentFile != null) cfg.environmentFile;
        ExecStart = "${cfg.package}/bin/mumble-server -ini /run/murmur/murmurd.ini";
        Restart = "always";
        LogsDirectory = lib.mkIf cfg.logToFile "murmur";
        LogsDirectoryMode = "0750";
        RuntimeDirectory = "murmur";
        RuntimeDirectoryMode = "0700";
        User = cfg.user;
@@ -403,8 +409,8 @@ in
        r /run/murmur/murmurd.ini,
        r ${configFile},
    ''
    + lib.optionalString (cfg.logFile != null) ''
      rw ${cfg.logFile},
    + lib.optionalString cfg.logToFile ''
      rw /var/log/murmur/murmurd.log,
    ''
    + lib.optionalString (cfg.sslCert != "") ''
      r ${cfg.sslCert},