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>

+6 -4
+5 -3
nixos/modules/services/web-servers/caddy/default.nix
··· 30 30 ${optionalString ( 31 31 hostOpts.useACMEHost != null 32 32 ) "tls ${sslCertDir}/cert.pem ${sslCertDir}/key.pem"} 33 - log { 34 - ${hostOpts.logFormat} 35 - } 33 + ${optionalString (hostOpts.logFormat != null) '' 34 + log { 35 + ${hostOpts.logFormat} 36 + } 37 + ''} 36 38 37 39 ${hostOpts.extraConfig} 38 40 }
+1 -1
nixos/modules/services/web-servers/caddy/vhost-options.nix
··· 56 56 }; 57 57 58 58 logFormat = mkOption { 59 - type = types.lines; 59 + type = types.nullOr types.lines; 60 60 default = '' 61 61 output file ${cfg.logDir}/access-${lib.replaceStrings [ "/" " " ] [ "_" "_" ] config.hostName}.log 62 62 '';