@@ -7,16 +7,6 @@ with lib;
77let
88
99 cfg = config.networking;
10− dnsmasqResolve = config.services.dnsmasq.enable &&
11− config.services.dnsmasq.resolveLocalQueries;
12− hasLocalResolver = config.services.bind.enable ||
13− config.services.unbound.enable ||
14− dnsmasqResolve;
15−
16− resolvconfOptions = cfg.resolvconfOptions
17− ++ optional cfg.dnsSingleRequest "single-request"
18− ++ optional cfg.dnsExtensionMechanism "edns0";
19−
2010
2111 localhostMapped4 = cfg.hosts ? "127.0.0.1" && elem "localhost" cfg.hosts."127.0.0.1";
2212 localhostMapped6 = cfg.hosts ? "::1" && elem "localhost" cfg.hosts."::1";
@@ -64,48 +54,6 @@ in
6454 '';
6555 };
6656
67− networking.dnsSingleRequest = lib.mkOption {
68− type = types.bool;
69− default = false;
70− description = ''
71− Recent versions of glibc will issue both ipv4 (A) and ipv6 (AAAA)
72− address queries at the same time, from the same port. Sometimes upstream
73− routers will systemically drop the ipv4 queries. The symptom of this problem is
74− that 'getent hosts example.com' only returns ipv6 (or perhaps only ipv4) addresses. The
75− workaround for this is to specify the option 'single-request' in
76− /etc/resolv.conf. This option enables that.
77− '';
78− };
79−
80− networking.dnsExtensionMechanism = lib.mkOption {
81− type = types.bool;
82− default = true;
83− description = ''
84− Enable the <code>edns0</code> option in <filename>resolv.conf</filename>. With
85− that option set, <code>glibc</code> supports use of the extension mechanisms for
86− DNS (EDNS) specified in RFC 2671. The most popular user of that feature is DNSSEC,
87− which does not work without it.
88− '';
89− };
90−
91− networking.extraResolvconfConf = lib.mkOption {
92− type = types.lines;
93− default = "";
94− example = "libc=NO";
95− description = ''
96− Extra configuration to append to <filename>resolvconf.conf</filename>.
97− '';
98− };
99−
100− networking.resolvconfOptions = lib.mkOption {
101− type = types.listOf types.str;
102− default = [];
103− example = [ "ndots:1" "rotate" ];
104− description = ''
105− Set the options in <filename>/etc/resolv.conf</filename>.
106− '';
107− };
108−
10957 networking.timeServers = mkOption {
11058 default = [
11159 "0.nixos.pool.ntp.org"
@@ -240,35 +188,6 @@ in
240188 # /etc/host.conf: resolver configuration file
241189 "host.conf".text = cfg.hostConf;
242190
243− # /etc/resolvconf.conf: Configuration for openresolv.
244− "resolvconf.conf".text =
245− ''
246− # This is the default, but we must set it here to prevent
247− # a collision with an apparently unrelated environment
248− # variable with the same name exported by dhcpcd.
249− interface_order='lo lo[0-9]*'
250− '' + optionalString config.services.nscd.enable ''
251− # Invalidate the nscd cache whenever resolv.conf is
252− # regenerated.
253− libc_restart='${pkgs.systemd}/bin/systemctl try-restart --no-block nscd.service 2> /dev/null'
254− '' + optionalString (length resolvconfOptions > 0) ''
255− # Options as described in resolv.conf(5)
256− resolv_conf_options='${concatStringsSep " " resolvconfOptions}'
257− '' + optionalString hasLocalResolver ''
258− # This hosts runs a full-blown DNS resolver.
259− name_servers='127.0.0.1'
260− '' + optionalString dnsmasqResolve ''
261− dnsmasq_conf=/etc/dnsmasq-conf.conf
262− dnsmasq_resolv=/etc/dnsmasq-resolv.conf
263− '' + cfg.extraResolvconfConf + ''
264− '';
265−
266− } // optionalAttrs config.services.resolved.enable {
267− # symlink the dynamic stub resolver of resolv.conf as recommended by upstream:
268− # https://www.freedesktop.org/software/systemd/man/systemd-resolved.html#/etc/resolv.conf
269− "resolv.conf".source = "/run/systemd/resolve/stub-resolv.conf";
270− } // optionalAttrs (config.services.resolved.enable && dnsmasqResolve) {
271− "dnsmasq-resolv.conf".source = "/run/systemd/resolve/resolv.conf";
272191 } // optionalAttrs (pkgs.stdenv.hostPlatform.libc == "glibc") {
273192 # /etc/rpc: RPC program numbers.
274193 "rpc".source = pkgs.glibc.out + "/etc/rpc";
@@ -295,29 +214,6 @@ in
295214 # Install the proxy environment variables
296215 environment.sessionVariables = cfg.proxy.envVars;
297216
298− # This is needed when /etc/resolv.conf is being overriden by networkd
299− # and other configurations. If the file is destroyed by an environment
300− # activation then it must be rebuilt so that applications which interface
301− # with /etc/resolv.conf directly don't break.
302− system.activationScripts.resolvconf = stringAfter [ "etc" "specialfs" "var" ]
303− ''
304− # Systemd resolved controls its own resolv.conf
305− rm -f /run/resolvconf/interfaces/systemd
306− ${optionalString config.services.resolved.enable ''
307− rm -rf /run/resolvconf/interfaces
308− mkdir -p /run/resolvconf/interfaces
309− ln -s /run/systemd/resolve/resolv.conf /run/resolvconf/interfaces/systemd
310− ''}
311−
312− # Make sure resolv.conf is up to date if not managed manually, by systemd or
313− # by NetworkManager
314− ${optionalString (!config.environment.etc?"resolv.conf" &&
315− (cfg.networkmanager.enable ->
316− cfg.networkmanager.rc-manager == "resolvconf")) ''
317− ${pkgs.openresolv}/bin/resolvconf -u
318− ''}
319− '';
320−
321217 };
322218
323219}