summary refs log tree commit diff
diff options
context:
space:
mode:
authorChristian Kauhaus <kc@flyingcircus.io>2019-11-29 12:08:34 +0100
committerChristian Kauhaus <kc@flyingcircus.io>2019-11-29 12:08:34 +0100
commit918c2ca01aabb31ec2d6c033a14039d0adbe87de (patch)
tree57eb2a5620c252337c2391cad28d9ef699596d9c
parent724133984f066ee7ad1592f08ae886a718eb31c6 (diff)
downloadnixpkgs-918c2ca01aabb31ec2d6c033a14039d0adbe87de.tar
nixpkgs-918c2ca01aabb31ec2d6c033a14039d0adbe87de.tar.gz
nixpkgs-918c2ca01aabb31ec2d6c033a14039d0adbe87de.tar.bz2
nixpkgs-918c2ca01aabb31ec2d6c033a14039d0adbe87de.tar.lz
nixpkgs-918c2ca01aabb31ec2d6c033a14039d0adbe87de.tar.xz
nixpkgs-918c2ca01aabb31ec2d6c033a14039d0adbe87de.tar.zst
nixpkgs-918c2ca01aabb31ec2d6c033a14039d0adbe87de.zip
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
-rw-r--r--nixos/modules/config/networking.nix17
-rw-r--r--nixos/modules/rename.nix1
-rw-r--r--nixos/tests/resolv.nix77
3 files changed, 81 insertions, 14 deletions
diff --git a/nixos/modules/config/networking.nix b/nixos/modules/config/networking.nix
index a89667ea221..3560e579e47 100644
--- a/nixos/modules/config/networking.nix
+++ b/nixos/modules/config/networking.nix
@@ -41,19 +41,6 @@ in
       '';
     };
 
-    networking.hostConf = lib.mkOption {
-      type = types.lines;
-      default = "multi on";
-      example = ''
-        multi on
-        reorder on
-        trim lan
-      '';
-      description = ''
-        The contents of <filename>/etc/host.conf</filename>. See also <citerefentry><refentrytitle>host.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
-      '';
-    };
-
     networking.timeServers = mkOption {
       default = [
         "0.nixos.pool.ntp.org"
@@ -186,7 +173,9 @@ in
         '';
 
         # /etc/host.conf: resolver configuration file
-        "host.conf".text = cfg.hostConf;
+        "host.conf".text = ''
+          multi on
+        '';
 
       } // optionalAttrs (pkgs.stdenv.hostPlatform.libc == "glibc") {
         # /etc/rpc: RPC program numbers.
diff --git a/nixos/modules/rename.nix b/nixos/modules/rename.nix
index e392fef54dd..83b29613d9c 100644
--- a/nixos/modules/rename.nix
+++ b/nixos/modules/rename.nix
@@ -239,6 +239,7 @@ with lib;
     (mkRemovedOptionModule [ "systemd" "generator-packages" ] "Use systemd.packages instead.")
     (mkRemovedOptionModule [ "fonts" "enableCoreFonts" ] "Use fonts.fonts = [ pkgs.corefonts ]; instead.")
     (mkRemovedOptionModule [ "networking" "vpnc" ] "Use environment.etc.\"vpnc/service.conf\" instead.")
+    (mkRemovedOptionModule [ "networking" "hostConf" ] "Use environment.etc.\"host.conf\" instead.")
 
     # ZSH
     (mkRenamedOptionModule [ "programs" "zsh" "enableSyntaxHighlighting" ] [ "programs" "zsh" "syntaxHighlighting" "enable" ])
diff --git a/nixos/tests/resolv.nix b/nixos/tests/resolv.nix
new file mode 100644
index 00000000000..37004bec558
--- /dev/null
+++ b/nixos/tests/resolv.nix
@@ -0,0 +1,77 @@
+# Test whether DNS resolving returns multiple records and all address families.
+import ./make-test-python.nix ({ pkgs, ... } : {
+  name = "resolv";
+  meta = with pkgs.stdenv.lib.maintainers; {
+    maintainers = [ ckauhaus ];
+  };
+
+  nodes.resolv = { ... }: {
+    networking.extraHosts = ''
+      # IPv4 only
+      192.0.2.1 host-ipv4.example.net
+      192.0.2.2 host-ipv4.example.net
+      # IP6 only
+      2001:db8::2:1 host-ipv6.example.net
+      2001:db8::2:2 host-ipv6.example.net
+      # dual stack
+      192.0.2.1 host-dual.example.net
+      192.0.2.2 host-dual.example.net
+      2001:db8::2:1 host-dual.example.net
+      2001:db8::2:2 host-dual.example.net
+    '';
+  };
+
+  testScript = let
+    getaddrinfo_py = pkgs.writeScript "getaddrinfo.py" ''
+      import socket
+      import sys
+
+      result = set()
+      for gai in socket.getaddrinfo(sys.argv[1], 0):
+          result.add(gai[4][0])
+
+      print(' '.join(sorted(list(result))))
+    '';
+
+    getaddrinfo = "${pkgs.python3.interpreter} ${getaddrinfo_py}";
+
+  in
+  ''
+    def compare(test, should, is_):
+        should = should.strip()
+        is_ = is_.strip()
+        resolv.log("{}: expected '{}', actual '{}'".format(test, should, is_))
+        if should == is_:
+            resolv.log("* OK")
+            return True
+        else:
+            resolv.log("* FAILED")
+            return False
+
+
+    start_all()
+    resolv.wait_for_unit("nscd")
+    res = []
+
+    out = resolv.succeed(
+        "${getaddrinfo} host-ipv4.example.net"
+    )
+    res.append(compare("resolve IPv4", "192.0.2.1 192.0.2.2", out))
+
+    out = resolv.succeed(
+        "${getaddrinfo} host-ipv6.example.net"
+    )
+    res.append(compare("resolve IPv6", "2001:db8::2:1 2001:db8::2:2", out))
+
+    out = resolv.succeed(
+        "${getaddrinfo} host-dual.example.net"
+    )
+    res.append(
+        compare(
+            "resolve dual stack", "192.0.2.1 192.0.2.2 2001:db8::2:1 2001:db8::2:2", out
+        )
+    )
+
+    assert all(res) is True
+  '';
+})