default = false; type = types.bool; description = '' <del> Use saved config, if any (and prefer over configuration passed with <option>services.caddy.config</option>). </del> <ins> Use saved config, if any (and prefer over any specified configuration passed with <literal>--config</literal>). </ins> ''; }; <del> ca = mkOption { default = "https://acme-v02.api.letsencrypt.org/directory"; example = "https://acme-staging-v02.api.letsencrypt.org/directory"; type = types.nullOr types.str; </del> <ins> extraConfig = mkOption { type = types.lines; default = ""; example = '' example.com { encode gzip log root /srv/http } ''; </ins> description = '' <del> Certificate authority ACME server. The default (Let's Encrypt production server) should be fine for most people. Set it to null if you don't want to include any authority (or if you want to write a more fine-graned configuration manually) </del> <ins> Additional lines of configuration appended to the automatically generated <literal>Caddyfile</literal>. </ins> ''; }; <del> email = mkOption { default = ""; type = types.str; description = "Email address (for Let's Encrypt certificate)"; </del> <ins> virtualHosts = mkOption { type = with types; attrsOf (submodule (import ./vhost-options.nix { inherit cfg; })); default = {}; example = literalExpression '' { "hydra.example.com" = { serverAliases = [ "www.hydra.example.com" ]; extraConfig = ''' encode gzip root /srv/http '''; }; }; ''; description = '' Declarative specification of virtual hosts served by Caddy. ''; </ins> }; <del> dataDir = mkOption { default = "/var/lib/caddy"; type = types.path; </del> <ins> acmeCA = mkOption { default = "https://acme-v02.api.letsencrypt.org/directory"; example = "https://acme-staging-v02.api.letsencrypt.org/directory"; type = with types; nullOr str; </ins> description = '' <del> The data directory, for storing certificates. Before 17.09, this would create a .caddy directory. With 17.09 the contents of the .caddy directory are in the specified data directory instead. </del> <ins> The URL to the ACME CA's directory. It is strongly recommended to set this to Let's Encrypt's staging endpoint for testing or development. </ins> <del> Caddy v2 replaced CADDYPATH with XDG directories. See https://caddyserver.com/docs/conventions#file-locations. </del> <ins> Set it to <literal>null</literal> if you want to write a more fine-grained configuration manually. </ins> ''; }; <del> package = mkOption { default = pkgs.caddy; defaultText = literalExpression "pkgs.caddy"; type = types.package; </del> <ins> email = mkOption { default = null; type = with types; nullOr str; </ins> description = '' <del> Caddy package to use. </del> <ins> Your email address. Mainly used when creating an ACME account with your CA, and is highly recommended in case there are problems with your certificates. </ins> ''; }; }; <ins> # implementation </ins> config = mkIf cfg.enable { <ins> assertions = [ { assertion = cfg.adapter != "caddyfile" -> cfg.configFile != configFile; message = "Any value other than 'caddyfile' is only valid when providing your own `services.caddy.configFile`"; } ]; services.caddy.extraConfig = concatMapStringsSep "n" mkVHostConf virtualHosts; </ins> systemd.packages = [ cfg.package ]; systemd.services.caddy = { <ins> wants = map (hostOpts: "acme-finished-${hostOpts.useACMEHost}.target") acmeVHosts; after = map (hostOpts: "acme-selfsigned-${hostOpts.useACMEHost}.service") acmeVHosts; before = map (hostOpts: "acme-${hostOpts.useACMEHost}.service") acmeVHosts; </ins> wantedBy = [ "multi-user.target" ]; startLimitIntervalSec = 14400; startLimitBurst = 10;