git.iko.soy/typeable/nixpkgs
on master help sign in
networking config: support setting resolv.conf options
14dfdebChristian Zagrodnick
nixos/modules/config/networking.nix+16−6
@@ -11,6 +11,11 @@ let
11 config.services.dnsmasq.resolveLocalQueries;
11 config.services.dnsmasq.resolveLocalQueries;
12 hasLocalResolver = config.services.bind.enable || dnsmasqResolve;
12 hasLocalResolver = config.services.bind.enable || dnsmasqResolve;
13
13
14+ resolvconfOptions =
15+ builtins.replaceStrings ["\n"] [" "]
16+ (cfg.resolvconfOptions +
17+ (optionalString cfg.dnsSingleRequest " single-request") +
18+ (optionalString cfg.dnsExtensionMechanism " ends0"));
14in
19in
15
20
16{
21{
@@ -59,6 +64,14 @@ in
59 '';
64 '';
60 };
65 };
61
66
67+ networking.resolvconfOptions = lib.mkOption {
68+ type = types.lines;
69+ default = "";
70+ example = "ndots:1 rotate";
71+ description = ''
72+ Set the options in <filename>/etc/resolv.conf</filename>.
73+ '';
74+ };
62
75
63 networking.proxy = {
76 networking.proxy = {
64
77
@@ -171,12 +184,9 @@ in
171 # Invalidate the nscd cache whenever resolv.conf is
184 # Invalidate the nscd cache whenever resolv.conf is
172 # regenerated.
185 # regenerated.
173 libc_restart='${pkgs.systemd}/bin/systemctl try-restart --no-block nscd.service 2> /dev/null'
186 libc_restart='${pkgs.systemd}/bin/systemctl try-restart --no-block nscd.service 2> /dev/null'
174− '' + optionalString cfg.dnsSingleRequest ''
187+ '' + optionalString ((stringLength resolvconfOptions) > 0) ''
175− # only send one DNS request at a time
188+ # Options as described in resolv.conf(5)
176− resolv_conf_options+=' single-request'
177− '' + optionalString cfg.dnsExtensionMechanism ''
178− # enable extension mechanisms for DNS
179− resolv_conf_options+=' edns0'
189+ resolv_conf_options='${resolvconfOptions}'
180 '' + optionalString hasLocalResolver ''
190 '' + optionalString hasLocalResolver ''
181 # This hosts runs a full-blown DNS resolver.
191 # This hosts runs a full-blown DNS resolver.
182 name_servers='127.0.0.1'
192 name_servers='127.0.0.1'