nixos/syslog-ng: Replace option serviceName with listenToJournal. Fix socket activation

This commit is contained in:
Rickard Nilsson 2014-10-14 15:20:27 +02:00
parent 958193aeb4
commit 54a0ac090c
2 changed files with 16 additions and 9 deletions

View File

@ -130,5 +130,6 @@ in zipModules ([]
++ obsolete' [ "boot" "initrd" "luks" "enable" ]
++ obsolete' [ "programs" "bash" "enable" ]
++ obsolete' [ "services" "samba" "defaultShare" ]
++ obsolete' [ "services" "syslog-ng" "serviceName" ]
)

View File

@ -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}";