From 64e3b6239b658a7ce1ce316330fe3c7d018da089 Mon Sep 17 00:00:00 2001 From: TQ Hirsch Date: Sat, 25 Feb 2023 16:11:53 +0100 Subject: [PATCH 1/4] pdns, pdns-recurser: Look for configuration in /etc This allows the respective management tools to find the config file without manually specifying it on each invocation. --- pkgs/servers/dns/pdns-recursor/default.nix | 3 +++ pkgs/servers/dns/pdns/default.nix | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/pkgs/servers/dns/pdns-recursor/default.nix b/pkgs/servers/dns/pdns-recursor/default.nix index aec253d26ed1..c8da5d9de60c 100644 --- a/pkgs/servers/dns/pdns-recursor/default.nix +++ b/pkgs/servers/dns/pdns-recursor/default.nix @@ -21,8 +21,11 @@ stdenv.mkDerivation rec { configureFlags = [ "--enable-reproducible" "--enable-systemd" + "sysconfdir=/etc/powerdns-recursor" ]; + installFlags = [ "sysconfdir=$(out)/etc/powerdns-recursor" ]; + enableParallelBuilding = true; passthru.tests = { diff --git a/pkgs/servers/dns/pdns/default.nix b/pkgs/servers/dns/pdns/default.nix index b41e4df5242a..e998a1e5cf98 100644 --- a/pkgs/servers/dns/pdns/default.nix +++ b/pkgs/servers/dns/pdns/default.nix @@ -69,6 +69,7 @@ stdenv.mkDerivation (finalAttrs: { "--with-libsodium" "--with-sqlite3" "--with-libcrypto=${openssl.dev}" + "sysconfdir=/etc/powerdns" ]; # nix destroy with-modules arguments, when using configureFlags @@ -79,6 +80,11 @@ stdenv.mkDerivation (finalAttrs: { ) ''; + # We want the various utilities to look for the powerdns config in + # /etc/powerdns, but to actually install the sample config file in + # $out + installFlags = [ "sysconfdir=$(out)/etc/powerdns" ]; + enableParallelBuilding = true; doCheck = true; From d25e5e21070cbacaa33361254a6a0b1e2e7c0e04 Mon Sep 17 00:00:00 2001 From: TQ Hirsch Date: Sat, 25 Feb 2023 16:33:36 +0100 Subject: [PATCH 2/4] nixos/powerdns, nixos/pdns-recurser: Symlink configuration into /etc This places a symlink to the running configuration where the admin tools expect it, allowing users to control the powerdns server or recursor without manually specifying a config file. --- nixos/modules/services/networking/pdns-recursor.nix | 2 ++ nixos/modules/services/networking/powerdns.nix | 2 ++ 2 files changed, 4 insertions(+) diff --git a/nixos/modules/services/networking/pdns-recursor.nix b/nixos/modules/services/networking/pdns-recursor.nix index 2f07cefc736e..af5ea08a3609 100644 --- a/nixos/modules/services/networking/pdns-recursor.nix +++ b/nixos/modules/services/networking/pdns-recursor.nix @@ -159,6 +159,8 @@ in { config = mkIf cfg.enable { + environment.etc."powerdns-recursor".source = configDir; + services.pdns-recursor.settings = mkDefaultAttrs { local-address = cfg.dns.address; local-port = cfg.dns.port; diff --git a/nixos/modules/services/networking/powerdns.nix b/nixos/modules/services/networking/powerdns.nix index 850a128cf1a4..fd82791f21c1 100644 --- a/nixos/modules/services/networking/powerdns.nix +++ b/nixos/modules/services/networking/powerdns.nix @@ -38,6 +38,8 @@ in { config = mkIf cfg.enable { + environment.etc.powerdns.source = finalConfigDir; + systemd.packages = [ pkgs.pdns ]; systemd.services.pdns = { From 8ab22ad2ad166a75e517bc3d0a6625d3e3f4517a Mon Sep 17 00:00:00 2001 From: TQ Hirsch Date: Sat, 25 Feb 2023 17:02:36 +0100 Subject: [PATCH 3/4] nixos/tests/powerdns: Stop manually configuring config path --- nixos/tests/powerdns.nix | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/nixos/tests/powerdns.nix b/nixos/tests/powerdns.nix index d3708d25f0fb..599d5ea67efe 100644 --- a/nixos/tests/powerdns.nix +++ b/nixos/tests/powerdns.nix @@ -28,8 +28,6 @@ import ./make-test-python.nix ({ pkgs, lib, ... }: { }; testScript = '' - import re - with subtest("PowerDNS database exists"): server.wait_for_unit("mysql") server.succeed("echo 'SHOW DATABASES;' | sudo -u pdns mysql -u pdns >&2") @@ -46,11 +44,7 @@ import ./make-test-python.nix ({ pkgs, lib, ... }: { with subtest("Adding an example zone works"): # Extract configuration file needed by pdnsutil - unit = server.succeed("systemctl cat pdns") - match = re.search("(--config-dir=[^ ]+)", unit) - assert(match is not None) - conf = match.group(1) - pdnsutil = "sudo -u pdns pdnsutil " + conf + pdnsutil = "sudo -u pdns pdnsutil " server.succeed(f"{pdnsutil} create-zone example.com ns1.example.com") server.succeed(f"{pdnsutil} add-record example.com ns1 A 192.168.1.2") From dd481f2ee3bcf8e0555968dbdaa03a45bd5ae56e Mon Sep 17 00:00:00 2001 From: TQ Hirsch Date: Thu, 29 Jun 2023 12:42:01 +0200 Subject: [PATCH 4/4] pdns: Changed paths in /etc to use pdns instead of powerdns --- nixos/modules/services/networking/pdns-recursor.nix | 2 +- nixos/modules/services/networking/powerdns.nix | 2 +- pkgs/servers/dns/pdns-recursor/default.nix | 4 ++-- pkgs/servers/dns/pdns/default.nix | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/nixos/modules/services/networking/pdns-recursor.nix b/nixos/modules/services/networking/pdns-recursor.nix index af5ea08a3609..f929532ba09f 100644 --- a/nixos/modules/services/networking/pdns-recursor.nix +++ b/nixos/modules/services/networking/pdns-recursor.nix @@ -159,7 +159,7 @@ in { config = mkIf cfg.enable { - environment.etc."powerdns-recursor".source = configDir; + environment.etc."pdns-recursor".source = configDir; services.pdns-recursor.settings = mkDefaultAttrs { local-address = cfg.dns.address; diff --git a/nixos/modules/services/networking/powerdns.nix b/nixos/modules/services/networking/powerdns.nix index fd82791f21c1..03bf93301d85 100644 --- a/nixos/modules/services/networking/powerdns.nix +++ b/nixos/modules/services/networking/powerdns.nix @@ -38,7 +38,7 @@ in { config = mkIf cfg.enable { - environment.etc.powerdns.source = finalConfigDir; + environment.etc.pdns.source = finalConfigDir; systemd.packages = [ pkgs.pdns ]; diff --git a/pkgs/servers/dns/pdns-recursor/default.nix b/pkgs/servers/dns/pdns-recursor/default.nix index c8da5d9de60c..da0890e8e4d0 100644 --- a/pkgs/servers/dns/pdns-recursor/default.nix +++ b/pkgs/servers/dns/pdns-recursor/default.nix @@ -21,10 +21,10 @@ stdenv.mkDerivation rec { configureFlags = [ "--enable-reproducible" "--enable-systemd" - "sysconfdir=/etc/powerdns-recursor" + "sysconfdir=/etc/pdns-recursor" ]; - installFlags = [ "sysconfdir=$(out)/etc/powerdns-recursor" ]; + installFlags = [ "sysconfdir=$(out)/etc/pdns-recursor" ]; enableParallelBuilding = true; diff --git a/pkgs/servers/dns/pdns/default.nix b/pkgs/servers/dns/pdns/default.nix index e998a1e5cf98..fcd218a1f3cc 100644 --- a/pkgs/servers/dns/pdns/default.nix +++ b/pkgs/servers/dns/pdns/default.nix @@ -69,7 +69,7 @@ stdenv.mkDerivation (finalAttrs: { "--with-libsodium" "--with-sqlite3" "--with-libcrypto=${openssl.dev}" - "sysconfdir=/etc/powerdns" + "sysconfdir=/etc/pdns" ]; # nix destroy with-modules arguments, when using configureFlags @@ -81,9 +81,9 @@ stdenv.mkDerivation (finalAttrs: { ''; # We want the various utilities to look for the powerdns config in - # /etc/powerdns, but to actually install the sample config file in + # /etc/pdns, but to actually install the sample config file in # $out - installFlags = [ "sysconfdir=$(out)/etc/powerdns" ]; + installFlags = [ "sysconfdir=$(out)/etc/pdns" ]; enableParallelBuilding = true; doCheck = true;