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' [ "boot" "initrd" "luks" "enable" ]
++ obsolete' [ "programs" "bash" "enable" ] ++ obsolete' [ "programs" "bash" "enable" ]
++ obsolete' [ "services" "samba" "defaultShare" ] ++ obsolete' [ "services" "samba" "defaultShare" ]
++ obsolete' [ "services" "syslog-ng" "serviceName" ]
) )

View File

@ -44,13 +44,13 @@ in {
The package providing syslog-ng binaries. The package providing syslog-ng binaries.
''; '';
}; };
serviceName = mkOption { listenToJournal = mkOption {
type = types.str; type = types.bool;
default = "syslog-ng"; default = true;
description = '' description = ''
The name of the systemd service that runs syslog-ng. Set this to Whether syslog-ng should listen to the syslog socket used
<literal>syslog</literal> if you want journald to automatically by journald, and therefore receive all logs that journald
forward all logs to syslog-ng. produces.
''; '';
}; };
extraModulePaths = mkOption { extraModulePaths = mkOption {
@ -76,12 +76,18 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
systemd.services."${cfg.serviceName}" = { systemd.sockets.syslog = mkIf cfg.listenToJournal {
wantedBy = [ "multi-user.target" ]; wantedBy = [ "sockets.target" ];
socketConfig.Service = "syslog-ng.service";
};
systemd.services.syslog-ng = {
description = "syslog-ng daemon";
preStart = "mkdir -p /{var,run}/syslog-ng"; 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 = { serviceConfig = {
Type = "notify"; Type = "notify";
Sockets = "syslog.socket"; Sockets = if cfg.listenToJournal then "syslog.socket" else null;
StandardOutput = "null"; StandardOutput = "null";
Restart = "on-failure"; Restart = "on-failure";
ExecStart = "${cfg.package}/sbin/syslog-ng ${concatStringsSep " " syslogngOptions}"; ExecStart = "${cfg.package}/sbin/syslog-ng ${concatStringsSep " " syslogngOptions}";