nixos/unbound: resolveLocalQueries with resolved

This adds support for services.unbound.resolveLocalQueries with
systemd-resolved by improving the general behavior similar to the
dnsmasq module.

With this change, it not only adjusts resolvconf (which is not used when
systemd-resolved is used) but also prepends the loopback addresses to
networking.nameservers.
This commit is contained in:
Clara Engler
2026-07-09 15:24:05 +02:00
parent e0fb6e9fc5
commit 64f1104dea
@@ -115,7 +115,7 @@ in
default = true;
description = ''
Whether unbound should resolve local queries (i.e. add 127.0.0.1 to
/etc/resolv.conf).
/etc/resolv.conf and set name servers to localhost respectively).
'';
};
@@ -276,6 +276,7 @@ in
resolvconf = {
useLocalResolver = mkDefault true;
};
nameservers = lib.mkBefore ([ "127.0.0.1" ] ++ (optional config.networking.enableIPv6 "::1"));
};
environment.etc."unbound/unbound.conf".source = confFile;