nixos/caddy: add globalConfig option

This commit is contained in:
Aaron Andersen 2022-01-06 09:21:33 -05:00
parent f6ee491278
commit 45477f7ce5

View File

@ -28,11 +28,7 @@ let
let
Caddyfile = pkgs.writeText "Caddyfile" ''
{
${optionalString (cfg.email != null) "email ${cfg.email}"}
${optionalString (cfg.acmeCA != null) "acme_ca ${cfg.acmeCA}"}
log {
${cfg.logFormat}
}
${cfg.globalConfig}
}
${cfg.extraConfig}
'';
@ -183,6 +179,26 @@ in
'';
};
globalConfig = mkOption {
type = types.lines;
default = "";
example = ''
debug
servers {
protocol {
experimental_http3
}
}
'';
description = ''
Additional lines of configuration appended to the global config section
of the <literal>Caddyfile</literal>.
Refer to <link xlink:href="https://caddyserver.com/docs/caddyfile/options#global-options"/>
for details on supported values.
'';
};
extraConfig = mkOption {
type = types.lines;
default = "";
@ -253,6 +269,13 @@ in
];
services.caddy.extraConfig = concatMapStringsSep "\n" mkVHostConf virtualHosts;
services.caddy.globalConfig = ''
${optionalString (cfg.email != null) "email ${cfg.email}"}
${optionalString (cfg.acmeCA != null) "acme_ca ${cfg.acmeCA}"}
log {
${cfg.logFormat}
}
'';
systemd.packages = [ cfg.package ];
systemd.services.caddy = {