9 cfg = config.services.acme-dns;
10 format = pkgs.formats.toml { };
18 domain = "acme-dns.example.com";
21 options.services.acme-dns = {
22 enable = mkEnableOption "acme-dns";
24 package = mkPackageOption pkgs "acme-dns" { };
28 Free-form settings written directly to the `acme-dns.cfg` file.
29 Refer to <https://github.com/joohoi/acme-dns/blob/master/README.md#configuration> for supported values.
34 type = types.submodule {
35 freeformType = format.type;
40 description = "IP+port combination to bind and serve the DNS server on.";
42 example = "127.0.0.1:53";
57 description = "Protocols to serve DNS responses on.";
63 description = "Domain name to serve the requests off of.";
69 description = "Zone name server.";
75 description = "Zone admin email address for `SOA`.";
76 example = "admin.example.com";
80 type = types.listOf types.str;
81 description = "Predefined DNS records served in addition to the `_acme-challenge` TXT records.";
82 example = literalExpression ''
84 # replace with your acme-dns server's public IPv4
85 "${domain}. A 198.51.100.1"
86 # replace with your acme-dns server's public IPv6
87 "${domain}. AAAA 2001:db8::1"
88 # ${domain} should resolve any *.${domain} records
89 "${domain}. NS ${domain}."
101 description = "Database engine to use.";
104 connection = mkOption {
106 description = "Database connection string.";
107 example = "postgres://user:password@localhost/acmedns";
108 default = "/var/lib/acme-dns/acme-dns.db";
115 description = "IP to bind the HTTP API on.";
117 example = "127.0.0.1";
122 description = "Listen port for the HTTP API.";
124 # acme-dns expects this value to be a string
128 disable_registration = mkOption {
130 description = "Whether to disable the HTTP registration endpoint.";
142 description = "TLS backend to use.";
148 loglevel = mkOption {
155 description = "Level to log on.";
164 config = lib.mkIf cfg.enable {
165 systemd.packages = [ cfg.package ];
166 systemd.services.acme-dns = {
167 wantedBy = [ "multi-user.target" ];
171 "${lib.getExe cfg.package} -c ${format.generate "acme-dns.toml" cfg.settings}"
173 StateDirectory = "acme-dns";
174 WorkingDirectory = "%S/acme-dns";