diff --git a/nixos/modules/services/networking/pdns-recursor.nix b/nixos/modules/services/networking/pdns-recursor.nix index 2f07cefc736e..f929532ba09f 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."pdns-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..03bf93301d85 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.pdns.source = finalConfigDir; + systemd.packages = [ pkgs.pdns ]; systemd.services.pdns = { 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") diff --git a/pkgs/servers/dns/pdns-recursor/default.nix b/pkgs/servers/dns/pdns-recursor/default.nix index aec253d26ed1..da0890e8e4d0 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/pdns-recursor" ]; + installFlags = [ "sysconfdir=$(out)/etc/pdns-recursor" ]; + enableParallelBuilding = true; passthru.tests = { diff --git a/pkgs/servers/dns/pdns/default.nix b/pkgs/servers/dns/pdns/default.nix index b41e4df5242a..fcd218a1f3cc 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/pdns" ]; # 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/pdns, but to actually install the sample config file in + # $out + installFlags = [ "sysconfdir=$(out)/etc/pdns" ]; + enableParallelBuilding = true; doCheck = true;