diff --git a/nixos/doc/manual/release-notes/rl-1709.xml b/nixos/doc/manual/release-notes/rl-1709.xml
index 6948c22cc88f..c16499a0c1d4 100644
--- a/nixos/doc/manual/release-notes/rl-1709.xml
+++ b/nixos/doc/manual/release-notes/rl-1709.xml
@@ -89,6 +89,15 @@ rmdir /var/lib/ipfs/.ipfs
The postgres default dataDir has changed from /var/db/postgres to /var/lib/postgresql/$psqlSchema where $psqlSchema is 9.6 for example.
+
+
+ The caddy service was previously using an extra
+ .caddy in the data directory specified with the
+ dataDir option. The contents of the
+ .caddy directory are now expected to be in the
+ dataDir.
+
+
diff --git a/nixos/modules/services/web-servers/caddy.nix b/nixos/modules/services/web-servers/caddy.nix
index 9ac1a08bb586..ee32a1c86d4d 100644
--- a/nixos/modules/services/web-servers/caddy.nix
+++ b/nixos/modules/services/web-servers/caddy.nix
@@ -36,7 +36,11 @@ in
dataDir = mkOption {
default = "/var/lib/caddy";
type = types.path;
- description = "The data directory, for storing certificates.";
+ description = ''
+ 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.
+ '';
};
package = mkOption {
@@ -52,6 +56,8 @@ in
description = "Caddy web server";
after = [ "network-online.target" ];
wantedBy = [ "multi-user.target" ];
+ environment = mkIf (versionAtLeast config.system.stateVersion "17.09")
+ { CADDYPATH = cfg.dataDir; };
serviceConfig = {
ExecStart = ''
${cfg.package.bin}/bin/caddy -root=/var/tmp -conf=${configFile} \