···
41
-
configDir = pkgs.writeTextDir "recursor.conf" (
42
-
concatStringsSep "\n" (flip mapAttrsToList cfg.settings (name: val: "${name}=${serialize val}"))
41
+
settingsFormat = pkgs.formats.yaml { };
mkDefaultAttrs = mapAttrs (n: v: mkDefault v);
45
+
mkForwardZone = mapAttrsToList (
48
+
forwarders = [ uri ];
53
+
if cfg.old-settings != { } then
54
+
# Convert recursor.conf to recursor.yml and merge it
56
+
conf = pkgs.writeText "recursor.conf" (
57
+
concatStringsSep "\n" (mapAttrsToList (name: val: "${name}=${serialize val}") cfg.old-settings)
60
+
yaml = settingsFormat.generate "recursor.yml" cfg.yaml-settings;
62
+
pkgs.runCommand "recursor-merged.yml" { } ''
63
+
${pkgs.pdns-recursor}/bin/rec_control show-yaml --config ${conf} > override.yml
64
+
${pkgs.yq-go}/bin/yq '. *= load("override.yml")' ${yaml} > $out
67
+
settingsFormat.generate "recursor.yml" cfg.yaml-settings;
···
178
-
settings = mkOption {
200
+
old-settings = mkOption {
example = literalExpression ''
···
210
+
Older PowerDNS Recursor settings. Use this option to configure
211
+
Recursor settings not exposed in a NixOS option or to bypass one.
212
+
See the full documentation at
213
+
<https://doc.powerdns.com/recursor/settings.html>
214
+
for the available options.
217
+
This option is provided for backward compatibility only
218
+
and will be removed in the next release of NixOS.
223
+
yaml-settings = mkOption {
224
+
type = settingsFormat.type;
226
+
example = literalExpression ''
229
+
log-common-errors = true;
PowerDNS Recursor settings. Use this option to configure Recursor
settings not exposed in a NixOS option or to bypass one.
See the full documentation at
191
-
<https://doc.powerdns.com/recursor/settings.html>
236
+
<https://doc.powerdns.com/recursor/yamlsettings.html>
for the available options.
···
config = mkIf cfg.enable {
208
-
environment.etc."pdns-recursor".source = configDir;
253
+
environment.etc."/pdns-recursor/recursor.yml".source = configFile;
210
-
services.pdns-recursor.settings = mkDefaultAttrs {
211
-
local-address = cfg.dns.address;
212
-
local-port = cfg.dns.port;
213
-
allow-from = cfg.dns.allowFrom;
255
+
services.pdns-recursor.yaml-settings = {
256
+
incoming = mkDefaultAttrs {
257
+
listen = cfg.dns.address;
258
+
port = cfg.dns.port;
259
+
allow_from = cfg.dns.allowFrom;
262
+
webservice = mkDefaultAttrs {
263
+
address = cfg.api.address;
264
+
port = cfg.api.port;
265
+
allow_from = cfg.api.allowFrom;
215
-
webserver-address = cfg.api.address;
216
-
webserver-port = cfg.api.port;
217
-
webserver-allow-from = cfg.api.allowFrom;
268
+
recursor = mkDefaultAttrs {
269
+
forward_zones = mkForwardZone cfg.forwardZones;
270
+
forward_zones_recurse = mkForwardZone cfg.forwardZonesRecurse;
271
+
export_etc_hosts = cfg.exportHosts;
272
+
serve_rfc1918 = cfg.serveRFC1918;
273
+
lua_config_file = pkgs.writeText "recursor.lua" cfg.luaConfig;
219
-
forward-zones = mapAttrsToList (zone: uri: "${zone}.=${uri}") cfg.forwardZones;
220
-
forward-zones-recurse = mapAttrsToList (zone: uri: "${zone}.=${uri}") cfg.forwardZonesRecurse;
221
-
export-etc-hosts = cfg.exportHosts;
222
-
dnssec = cfg.dnssecValidation;
223
-
serve-rfc1918 = cfg.serveRFC1918;
224
-
lua-config-file = pkgs.writeText "recursor.lua" cfg.luaConfig;
278
+
dnssec = mkDefaultAttrs {
279
+
validation = cfg.dnssecValidation;
228
-
log-timestamp = false;
229
-
disable-syslog = true;
282
+
logging = mkDefaultAttrs {
284
+
disable_syslog = true;
systemd.packages = [ pkgs.pdns-recursor ];
234
-
systemd.services.pdns-recursor = {
235
-
wantedBy = [ "multi-user.target" ];
240
-
"${pkgs.pdns-recursor}/bin/pdns_recursor --config-dir=${configDir}"
290
+
systemd.services.pdns-recursor.wantedBy = [ "multi-user.target" ];
users.users.pdns-recursor = {
···
users.groups.pdns-recursor = { };
300
+
warnings = lib.optional (cfg.old-settings != { }) ''
301
+
pdns-recursor has changed its configuration file format from pdns-recursor.conf
302
+
(mapped to `services.pdns-recursor.old-settings`) to the newer pdns-recursor.yml
303
+
(mapped to `services.pdns-recursor.yaml-settings`).
305
+
Support for the older format will be removed in a future version, so please migrate
306
+
your settings over. See <https://doc.powerdns.com/recursor/yamlsettings.html>.
···
] "To change extra Recursor settings use services.pdns-recursor.settings instead.")
318
+
(mkRenamedOptionModule
meta.maintainers = with lib.maintainers; [ rnhmjoj ];