Change:
serviceConfig = { # https://www.freedesktop.org/software/systemd/man/systemd.service.html#ExecStart= # If the empty string is assigned to this option, the list of commands to start is reset, prior assignments of this option will have no effect. <del> ExecStart = [ "" "${cfg.package}/bin/caddy run ${optionalString cfg.resume "--resume"} --config ${configJSON}" ]; ExecReload = [ "" "${cfg.package}/bin/caddy reload --config ${configJSON}" ]; </del> <ins> ExecStart = [ "" "${cfg.package}/bin/caddy run --config ${cfg.configFile} --adapter ${cfg.adapter} ${optionalString cfg.resume "--resume"}" ]; ExecReload = [ "" "${cfg.package}/bin/caddy reload --config ${cfg.configFile} --adapter ${cfg.adapter}" ]; ExecStartPre = "${cfg.package}/bin/caddy validate --config ${cfg.configFile} --adapter ${cfg.adapter}"; </ins> User = cfg.user; Group = cfg.group; ReadWriteDirectories = cfg.dataDir; <ins> StateDirectory = mkIf (cfg.dataDir == "/var/lib/caddy") [ "caddy" ]; LogsDirectory = mkIf (cfg.logDir == "/var/log/caddy") [ "caddy" ]; </ins> Restart = "on-abnormal"; <ins> SupplementaryGroups = mkIf (length acmeVHosts != 0) [ "acme" ]; </ins> # TODO: attempt to upstream these options NoNewPrivileges = true;

Discussion:
Describe the bug When i try to import a config file, i get an error: When i copy the exact same text in , it does work. The file does exist and i can read it, even with the caddy user! So this seem to be a bug. To Reproduce Steps to reproduce the behavior: ... ... ... Expected behavior A clear and concise description of what you expected to happen. Additional context Add any other context about the problem here. Notify maintainers Metadata system: host os: multi-user?: sandbox: version: channels(root): nixpkgs: Maintainer information:
Without knowing anything about my first guess would be this: Is it possible this command is evaluating your configuration? If so, the issue is that the command is being run sandboxed so has no access outside the sandbox to your file. Build time commands can be tough.
That would make sense. So NixOS brakes the import feature.
Out of curiosity can you please paste your relevant config?
what exactly do you want to see? For a workaround, i just copied everything into the NixOS option: But in some cases, it's nice to have the webserver config. together with the website sourcecode:
Thanks for posting. The context helps. I think this is what you want:
It could make sense to add an off-by-default option to opt-out build-time configuration check.
Given my above solution, I'm not sure what value it would offer in this scenario. What scenario did you have in mind Can this config file hold secrets maybe?
Then you don't have to use such a workaround on NixOS and can just use it as described in it's documentation. There can be secrets in it, but i don't see how that's relevant here:
Hi, module maintainer here. I was the person who made the original PR for adapting s for Caddy 2, and I had no idea about the directive at the time. The motivation was to generate TLS settings from the module options and merge them with JSON-ified . Please use as suggested for now, and I'll see how I can make this easier in the future.
I marked this as stale due to inactivity. &rarr;