summary refs log tree commit diff
path: root/nixos/tests/nsd.nix
diff options
context:
space:
mode:
authoraszlig <aszlig@nix.build>2018-05-07 03:59:38 +0200
committeraszlig <aszlig@nix.build>2018-05-07 04:05:41 +0200
commit1eeeceb9c7e52734536a4e10323634d4ada2f27e (patch)
treef0f7f4f28b51b08d235cdd1f56a5eb793833a764 /nixos/tests/nsd.nix
parent2b499afa63f01473a19c7166c1f3750fa45a1bab (diff)
downloadnixpkgs-1eeeceb9c7e52734536a4e10323634d4ada2f27e.tar
nixpkgs-1eeeceb9c7e52734536a4e10323634d4ada2f27e.tar.gz
nixpkgs-1eeeceb9c7e52734536a4e10323634d4ada2f27e.tar.bz2
nixpkgs-1eeeceb9c7e52734536a4e10323634d4ada2f27e.tar.lz
nixpkgs-1eeeceb9c7e52734536a4e10323634d4ada2f27e.tar.xz
nixpkgs-1eeeceb9c7e52734536a4e10323634d4ada2f27e.tar.zst
nixpkgs-1eeeceb9c7e52734536a4e10323634d4ada2f27e.zip
nixos/nsd: Allow to configure root zone
When trying to run NSD to serve the root zone, one gets the following
error message:

error: illegal name: '.'

This is because the name of the zone is used as the derivation name for
building the zone file. However, Nix doesn't allow derivation names
starting with a period.

So whenever the zone is "." now, the file name generated is "root"
instead of ".".

I also added an assertion that makes sure the user sets
services.nsd.rootServer, otherwise NSD will fail at runtime because it
prevents serving the root zone without an explicit compile-time option.

Tested this by adding a root zone to the "nsd" NixOS VM test.

Signed-off-by: aszlig <aszlig@nix.build>
Cc: @hrdinka, @qknight
Diffstat (limited to 'nixos/tests/nsd.nix')
-rw-r--r--nixos/tests/nsd.nix9
1 files changed, 9 insertions, 0 deletions
diff --git a/nixos/tests/nsd.nix b/nixos/tests/nsd.nix
index ad4d4f82243..c3c91e71b5c 100644
--- a/nixos/tests/nsd.nix
+++ b/nixos/tests/nsd.nix
@@ -41,6 +41,7 @@ in import ./make-test.nix ({ pkgs, ...} : {
         { address = "dead:beef::1"; prefixLength = 64; }
       ];
       services.nsd.enable = true;
+      services.nsd.rootServer = true;
       services.nsd.interfaces = lib.mkForce [];
       services.nsd.zones."example.com.".data = ''
         @ SOA ns.example.com noc.example.com 666 7200 3600 1209600 3600
@@ -55,6 +56,11 @@ in import ./make-test.nix ({ pkgs, ...} : {
         @ A 9.8.7.6
         @ AAAA fedc::bbaa
       '';
+      services.nsd.zones.".".data = ''
+        @ SOA ns.example.com noc.example.com 666 7200 3600 1209600 3600
+        root A 1.8.7.4
+        root AAAA acbd::4
+      '';
     };
   };
 
@@ -86,6 +92,9 @@ in import ./make-test.nix ({ pkgs, ...} : {
 
         assertHost($_, "a", "deleg.example.com", qr/address 9.8.7.6$/);
         assertHost($_, "aaaa", "deleg.example.com", qr/address fedc::bbaa$/);
+
+        assertHost($_, "a", "root", qr/address 1.8.7.4$/);
+        assertHost($_, "aaaa", "root", qr/address acbd::4$/);
       };
     }
   '';