Skip to content

Commit

Permalink
Merge pull request NixOS#218280 from thequux/set-pdns-config-dir
Browse files Browse the repository at this point in the history
powerdns, pdns-recursor: find config in /etc by default
  • Loading branch information
NickCao authored Jul 1, 2023
2 parents dd38202 + dd481f2 commit 99d4bf7
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
2 changes: 2 additions & 0 deletions nixos/modules/services/networking/pdns-recursor.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions nixos/modules/services/networking/powerdns.nix
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ in {

config = mkIf cfg.enable {

environment.etc.pdns.source = finalConfigDir;

systemd.packages = [ pkgs.pdns ];

systemd.services.pdns = {
Expand Down
8 changes: 1 addition & 7 deletions nixos/tests/powerdns.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand Down
3 changes: 3 additions & 0 deletions pkgs/servers/dns/pdns-recursor/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
6 changes: 6 additions & 0 deletions pkgs/servers/dns/pdns/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;

Expand Down

0 comments on commit 99d4bf7

Please sign in to comment.