mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-06-05 21:03:40 +00:00
nixos/pdns-recursor: remove old-settings
This commit is contained in:
@@ -48,23 +48,6 @@ let
|
||||
}
|
||||
);
|
||||
|
||||
configFile =
|
||||
if cfg.old-settings != { } then
|
||||
# Convert recursor.conf to recursor.yml and merge it
|
||||
let
|
||||
conf = pkgs.writeText "recursor.conf" (
|
||||
concatStringsSep "\n" (mapAttrsToList (name: val: "${name}=${serialize val}") cfg.old-settings)
|
||||
);
|
||||
|
||||
yaml = settingsFormat.generate "recursor.yml" cfg.yaml-settings;
|
||||
in
|
||||
pkgs.runCommand "recursor-merged.yml" { } ''
|
||||
${pkgs.pdns-recursor}/bin/rec_control show-yaml --config ${conf} > override.yml
|
||||
${pkgs.yq-go}/bin/yq '. *= load("override.yml")' ${yaml} > $out
|
||||
''
|
||||
else
|
||||
settingsFormat.generate "recursor.yml" cfg.yaml-settings;
|
||||
|
||||
in
|
||||
{
|
||||
options.services.pdns-recursor = {
|
||||
@@ -196,30 +179,7 @@ in
|
||||
'';
|
||||
};
|
||||
|
||||
old-settings = mkOption {
|
||||
type = configType;
|
||||
default = { };
|
||||
example = literalExpression ''
|
||||
{
|
||||
loglevel = 8;
|
||||
log-common-errors = true;
|
||||
}
|
||||
'';
|
||||
description = ''
|
||||
Older 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
|
||||
<https://doc.powerdns.com/recursor/settings.html>
|
||||
for the available options.
|
||||
|
||||
::: {.warning}
|
||||
This option is provided for backward compatibility only
|
||||
and will be removed in the next release of NixOS.
|
||||
:::
|
||||
'';
|
||||
};
|
||||
|
||||
yaml-settings = mkOption {
|
||||
settings = mkOption {
|
||||
type = settingsFormat.type;
|
||||
default = { };
|
||||
example = literalExpression ''
|
||||
@@ -249,11 +209,12 @@ in
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
|
||||
environment.etc."/pdns-recursor/recursor.yml".source = configFile;
|
||||
environment.etc."/pdns-recursor/recursor.yml".source =
|
||||
settingsFormat.generate "recursor.yml" cfg.settings;
|
||||
|
||||
networking.resolvconf.useLocalResolver = lib.mkDefault true;
|
||||
|
||||
services.pdns-recursor.yaml-settings = {
|
||||
services.pdns-recursor.settings = {
|
||||
incoming = mkDefaultAttrs {
|
||||
listen = cfg.dns.address;
|
||||
port = cfg.dns.port;
|
||||
@@ -301,15 +262,6 @@ in
|
||||
|
||||
users.groups.pdns-recursor = { };
|
||||
|
||||
warnings = lib.optional (cfg.old-settings != { }) ''
|
||||
pdns-recursor has changed its configuration file format from pdns-recursor.conf
|
||||
(mapped to `services.pdns-recursor.old-settings`) to the newer pdns-recursor.yml
|
||||
(mapped to `services.pdns-recursor.yaml-settings`).
|
||||
|
||||
Support for the older format will be removed in a future version, so please migrate
|
||||
your settings over. See <https://doc.powerdns.com/recursor/yamlsettings.html>.
|
||||
'';
|
||||
|
||||
};
|
||||
|
||||
imports = [
|
||||
@@ -320,16 +272,32 @@ in
|
||||
] "To change extra Recursor settings use services.pdns-recursor.settings instead.")
|
||||
|
||||
(mkRenamedOptionModule
|
||||
[
|
||||
"services"
|
||||
"pdns-recursor"
|
||||
"yaml-settings"
|
||||
]
|
||||
[
|
||||
"services"
|
||||
"pdns-recursor"
|
||||
"settings"
|
||||
]
|
||||
)
|
||||
|
||||
(mkRemovedOptionModule
|
||||
[
|
||||
"services"
|
||||
"pdns-recursor"
|
||||
"old-settings"
|
||||
]
|
||||
''
|
||||
pdns-recursor has changed its configuration file format from pdns-recursor.conf
|
||||
(mapped to `services.pdns-recursor.old-settings`) to the newer pdns-recursor.yml
|
||||
(mapped to `services.pdns-recursor.settings`).
|
||||
|
||||
Support for the older format has been removed, please migrate your settings over.
|
||||
See <https://doc.powerdns.com/recursor/yamlsettings.html>.
|
||||
''
|
||||
)
|
||||
];
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
nodes.server = {
|
||||
services.pdns-recursor.enable = true;
|
||||
services.pdns-recursor.exportHosts = true;
|
||||
services.pdns-recursor.old-settings.dnssec-log-bogus = true;
|
||||
networking.hosts."192.0.2.1" = [ "example.com" ];
|
||||
};
|
||||
|
||||
@@ -18,8 +17,5 @@
|
||||
|
||||
with subtest("can resolve names"):
|
||||
assert "192.0.2.1" in server.succeed("host example.com localhost")
|
||||
|
||||
with subtest("old-settings have been merged in"):
|
||||
server.succeed("${lib.getExe pkgs.yq-go} -e .dnssec.log_bogus /etc/pdns-recursor/recursor.yml")
|
||||
'';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user