nixos/caddy: add resume option

Without this option all changes done with Caddy API are lost after reboot.

Current service is not supporting Caddy --resume parameter. There is reference to original unit https://github.com/caddyserver/dist/blob/master/init/caddy.service which also mentions --resume and that it should be used if new Caddy API will be used.
This commit is contained in:
Martin Minka 2020-12-13 23:14:56 +01:00 committed by Raphael Megzari
parent ec6dee00ec
commit 22719ca7de

View file

@ -90,6 +90,14 @@ in
''; '';
}; };
resume = mkOption {
default = false;
type = types.bool;
description = ''
Use saved config, if any (and prefer over configuration passed with <option>services.caddy.config</option>).
'';
};
ca = mkOption { ca = mkOption {
default = "https://acme-v02.api.letsencrypt.org/directory"; default = "https://acme-v02.api.letsencrypt.org/directory";
example = "https://acme-staging-v02.api.letsencrypt.org/directory"; example = "https://acme-staging-v02.api.letsencrypt.org/directory";
@ -142,7 +150,7 @@ in
startLimitIntervalSec = 14400; startLimitIntervalSec = 14400;
startLimitBurst = 10; startLimitBurst = 10;
serviceConfig = { serviceConfig = {
ExecStart = "${cfg.package}/bin/caddy run --config ${configJSON}"; ExecStart = "${cfg.package}/bin/caddy run ${optionalString cfg.resume "--resume"} --config ${configJSON}";
ExecReload = "${cfg.package}/bin/caddy reload --config ${configJSON}"; ExecReload = "${cfg.package}/bin/caddy reload --config ${configJSON}";
Type = "simple"; Type = "simple";
User = cfg.user; User = cfg.user;