git.iko.soy/typeable/nixpkgs
on master help sign in
Remove networking.hostConf option

This PR is part of the networking.* namespace cleanup. We feel that networking.hostConf is rarely used and provides little value compared to using environment.etc."host.conf" directly. Provide sensible default: multi on

commit918c2ca01aabb31ec2d6c033a14039d0adbe87de authorChristian Kauhaus <kc@flyingcircus.io> dateFri 29 Nov 2019, 12:08 (7 years ago) parent7241339
3 files changed+81−14
nixos/modules/config/networking.nix+3−14 nixos/modules/rename.nix+1 nixos/tests/resolv.nix+77
nixos/modules/config/networking.nix+3−14
@@ -41,19 +41,6 @@ in
4141 '';
4242 };
4343
44− networking.hostConf = lib.mkOption {
45− type = types.lines;
46− default = "multi on";
47− example = ''
48− multi on
49− reorder on
50− trim lan
51− '';
52− description = ''
53− The contents of <filename>/etc/host.conf</filename>. See also <citerefentry><refentrytitle>host.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
54− '';
55− };
56−
5744 networking.timeServers = mkOption {
5845 default = [
5946 "0.nixos.pool.ntp.org"
@@ -186,7 +173,9 @@ in
186173 '';
187174
188175 # /etc/host.conf: resolver configuration file
189− "host.conf".text = cfg.hostConf;
176+ "host.conf".text = ''
177+ multi on
178+ '';
190179
191180 } // optionalAttrs (pkgs.stdenv.hostPlatform.libc == "glibc") {
192181 # /etc/rpc: RPC program numbers.
nixos/modules/rename.nix+1
@@ -239,6 +239,7 @@ with lib;
239239 (mkRemovedOptionModule [ "systemd" "generator-packages" ] "Use systemd.packages instead.")
240240 (mkRemovedOptionModule [ "fonts" "enableCoreFonts" ] "Use fonts.fonts = [ pkgs.corefonts ]; instead.")
241241 (mkRemovedOptionModule [ "networking" "vpnc" ] "Use environment.etc.\"vpnc/service.conf\" instead.")
242+ (mkRemovedOptionModule [ "networking" "hostConf" ] "Use environment.etc.\"host.conf\" instead.")
242243
243244 # ZSH
244245 (mkRenamedOptionModule [ "programs" "zsh" "enableSyntaxHighlighting" ] [ "programs" "zsh" "syntaxHighlighting" "enable" ])
nixos/tests/resolv.nixnew file+77
@@ -0,0 +1,77 @@
1+# Test whether DNS resolving returns multiple records and all address families.
2+import ./make-test-python.nix ({ pkgs, ... } : {
3+ name = "resolv";
4+ meta = with pkgs.stdenv.lib.maintainers; {
5+ maintainers = [ ckauhaus ];
6+ };
7+
8+ nodes.resolv = { ... }: {
9+ networking.extraHosts = ''
10+ # IPv4 only
11+ 192.0.2.1 host-ipv4.example.net
12+ 192.0.2.2 host-ipv4.example.net
13+ # IP6 only
14+ 2001:db8::2:1 host-ipv6.example.net
15+ 2001:db8::2:2 host-ipv6.example.net
16+ # dual stack
17+ 192.0.2.1 host-dual.example.net
18+ 192.0.2.2 host-dual.example.net
19+ 2001:db8::2:1 host-dual.example.net
20+ 2001:db8::2:2 host-dual.example.net
21+ '';
22+ };
23+
24+ testScript = let
25+ getaddrinfo_py = pkgs.writeScript "getaddrinfo.py" ''
26+ import socket
27+ import sys
28+
29+ result = set()
30+ for gai in socket.getaddrinfo(sys.argv[1], 0):
31+ result.add(gai[4][0])
32+
33+ print(' '.join(sorted(list(result))))
34+ '';
35+
36+ getaddrinfo = "${pkgs.python3.interpreter} ${getaddrinfo_py}";
37+
38+ in
39+ ''
40+ def compare(test, should, is_):
41+ should = should.strip()
42+ is_ = is_.strip()
43+ resolv.log("{}: expected '{}', actual '{}'".format(test, should, is_))
44+ if should == is_:
45+ resolv.log("* OK")
46+ return True
47+ else:
48+ resolv.log("* FAILED")
49+ return False
50+
51+
52+ start_all()
53+ resolv.wait_for_unit("nscd")
54+ res = []
55+
56+ out = resolv.succeed(
57+ "${getaddrinfo} host-ipv4.example.net"
58+ )
59+ res.append(compare("resolve IPv4", "192.0.2.1 192.0.2.2", out))
60+
61+ out = resolv.succeed(
62+ "${getaddrinfo} host-ipv6.example.net"
63+ )
64+ res.append(compare("resolve IPv6", "2001:db8::2:1 2001:db8::2:2", out))
65+
66+ out = resolv.succeed(
67+ "${getaddrinfo} host-dual.example.net"
68+ )
69+ res.append(
70+ compare(
71+ "resolve dual stack", "192.0.2.1 192.0.2.2 2001:db8::2:1 2001:db8::2:2", out
72+ )
73+ )
74+
75+ assert all(res) is True
76+ '';
77+})