From 54a0ac090c9c7cda53a110e4790d22d59e66eef3 Mon Sep 17 00:00:00 2001 From: Rickard Nilsson <rickynils@gmail.com> Date: Tue, 14 Oct 2014 15:20:27 +0200 Subject: [PATCH] nixos/syslog-ng: Replace option serviceName with listenToJournal. Fix socket activation --- nixos/modules/rename.nix | 1 + nixos/modules/services/logging/syslog-ng.nix | 24 ++++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/nixos/modules/rename.nix b/nixos/modules/rename.nix index 019fbc721b17..073a22207652 100644 --- a/nixos/modules/rename.nix +++ b/nixos/modules/rename.nix @@ -130,5 +130,6 @@ in zipModules ([] ++ obsolete' [ "boot" "initrd" "luks" "enable" ] ++ obsolete' [ "programs" "bash" "enable" ] ++ obsolete' [ "services" "samba" "defaultShare" ] +++ obsolete' [ "services" "syslog-ng" "serviceName" ] ) diff --git a/nixos/modules/services/logging/syslog-ng.nix b/nixos/modules/services/logging/syslog-ng.nix index 4a16b19134a0..64b288a11cd3 100644 --- a/nixos/modules/services/logging/syslog-ng.nix +++ b/nixos/modules/services/logging/syslog-ng.nix @@ -44,13 +44,13 @@ in { The package providing syslog-ng binaries. ''; }; - serviceName = mkOption { - type = types.str; - default = "syslog-ng"; + listenToJournal = mkOption { + type = types.bool; + default = true; description = '' - The name of the systemd service that runs syslog-ng. Set this to - <literal>syslog</literal> if you want journald to automatically - forward all logs to syslog-ng. + Whether syslog-ng should listen to the syslog socket used + by journald, and therefore receive all logs that journald + produces. ''; }; extraModulePaths = mkOption { @@ -76,12 +76,18 @@ in { }; config = mkIf cfg.enable { - systemd.services."${cfg.serviceName}" = { - wantedBy = [ "multi-user.target" ]; + systemd.sockets.syslog = mkIf cfg.listenToJournal { + wantedBy = [ "sockets.target" ]; + socketConfig.Service = "syslog-ng.service"; + }; + systemd.services.syslog-ng = { + description = "syslog-ng daemon"; preStart = "mkdir -p /{var,run}/syslog-ng"; + wantedBy = optional (!cfg.listenToJournal) "multi-user.target"; + after = [ "multi-user.target" ]; # makes sure hostname etc is set serviceConfig = { Type = "notify"; - Sockets = "syslog.socket"; + Sockets = if cfg.listenToJournal then "syslog.socket" else null; StandardOutput = "null"; Restart = "on-failure"; ExecStart = "${cfg.package}/sbin/syslog-ng ${concatStringsSep " " syslogngOptions}";