Change:
''; }; <ins> listenAddresses = mkOption { type = with types; listOf str; description = '' A list of host interfaces to bind to for this virtual host. ''; default = [ ]; example = [ "127.0.0.1" "::1" ]; }; useACMEHost = mkOption { type = types.nullOr types.str; default = null; description = '' A host of an existing Let's Encrypt certificate to use. This is mostly useful if you use DNS challenges but Caddy does not currently support your provider. <emphasis>Note that this option does not create any certificates, nor does it add subdomains to existing ones – you will need to create them manually using <xref linkend="opt-security.acme.certs"/>. Additionally, you should probably add the <literal>caddy</literal> user to the <literal>acme</literal> group to grant access to the certificates.</emphasis> ''; }; logFormat = mkOption { type = types.lines; default = '' output file ${cfg.logDir}/access-${config.hostName}.log ''; defaultText = '' output file ''${config.services.caddy.logDir}/access-''${hostName}.log ''; example = literalExpression '' mkForce ''' output discard '''; ''; description = '' Configuration for HTTP request logging (also known as access logs). See <link xlink:href="https://caddyserver.com/docs/caddyfile/directives/log#log"/> for details. ''; }; </ins> extraConfig = mkOption { type = types.lines; default = ""; description = '' <del> These lines go into the vhost verbatim </del> <ins> Additional lines of configuration appended to this virtual host in the automatically generated <literal>Caddyfile</literal>. </ins> ''; }; }; }

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;