djbdns: fix root server list at build time

as suggested by @peterhoeg in
https://github.com/NixOS/nixpkgs/commit/1b7e5eaa79241080eac2a0b79883a17c9e5f4731#commitcomment-24560631

fixes #30379

Changed files
+10 -5
nixos
modules
services
networking
pkgs
tools
networking
djbdns
+7 -4
nixos/modules/services/networking/dnscache.nix
···
'') ips}
'') cfg.domainServers)}
-
# djbdns contains an outdated list of root servers;
-
# if one was not provided in config, provide a current list
-
if [ ! -e servers/@ ]; then
-
awk '/^.?.ROOT-SERVERS.NET/ { print $4 }' ${pkgs.dns-root-data}/root.hints > $out/servers/@
fi
'';
···
'') ips}
'') cfg.domainServers)}
+
# if a list of root servers was not provided in config, copy it
+
# over. (this is also done by dnscache-conf, but we 'rm -rf
+
# /var/lib/dnscache/root' below & replace it wholesale with this,
+
# so we have to ensure servers/@ exists ourselves.)
+
if [ ! -e $out/servers/@ ]; then
+
# symlink does not work here, due chroot
+
cp ${pkgs.djbdns}/etc/dnsroots.global $out/servers/@;
fi
'';
+3 -1
pkgs/tools/networking/djbdns/default.nix
···
-
{ stdenv, fetchurl, glibc } :
let
version = "1.05";
···
postPatch = ''
echo gcc -O2 -include ${glibc.dev}/include/errno.h > conf-cc
echo $out > conf-home
sed -i "s|/etc/dnsroots.global|$out/etc/dnsroots.global|" dnscache-conf.c
'';
···
+
{ stdenv, fetchurl, glibc, dns-root-data } :
let
version = "1.05";
···
postPatch = ''
echo gcc -O2 -include ${glibc.dev}/include/errno.h > conf-cc
echo $out > conf-home
+
# djbdns ships with an outdated list of root servers
+
awk '/^.?.ROOT-SERVERS.NET/ { print $4 }' ${dns-root-data}/root.hints > dnsroots.global
sed -i "s|/etc/dnsroots.global|$out/etc/dnsroots.global|" dnscache-conf.c
'';