nixos/caddy: Make virtualHosts' logFormat optional

Allow `services.caddy.virtualHosts.<name>.logFormat` to be null, and in
that case, do not add a `log {}` block to the Caddy configuration. This
makes it possible to have multiple loggers declared in the global
configuration, and instruct Caddy to use a logger by name.

Signed-off-by: Gergely Nagy <me@gergo.csillger.hu>

Changed files
+6 -4
nixos
modules
services
web-servers
+5 -3
nixos/modules/services/web-servers/caddy/default.nix
···
${optionalString (
hostOpts.useACMEHost != null
) "tls ${sslCertDir}/cert.pem ${sslCertDir}/key.pem"}
-
log {
-
${hostOpts.logFormat}
-
}
+
${optionalString (hostOpts.logFormat != null) ''
+
log {
+
${hostOpts.logFormat}
+
}
+
''}
${hostOpts.extraConfig}
}
+1 -1
nixos/modules/services/web-servers/caddy/vhost-options.nix
···
};
logFormat = mkOption {
-
type = types.lines;
+
type = types.nullOr types.lines;
default = ''
output file ${cfg.logDir}/access-${lib.replaceStrings [ "/" " " ] [ "_" "_" ] config.hostName}.log
'';