diff --git a/nixos/modules/services/networking/bind.nix b/nixos/modules/services/networking/bind.nix index 763283dfe7a2..7775a4bd87fe 100644 --- a/nixos/modules/services/networking/bind.nix +++ b/nixos/modules/services/networking/bind.nix @@ -27,6 +27,7 @@ let forwarders { ${concatMapStrings (entry: " ${entry}; ") cfg.forwarders} }; directory "/var/run/named"; pid-file "/var/run/named/named.pid"; + ${cfg.extraOptions} }; ${cfg.extraConfig} @@ -141,6 +142,15 @@ in "; }; + extraOptions = mkOption { + type = types.lines; + default = ""; + description = '' + Extra lines to be added verbatim to the options section of the + generated named configuration file. + ''; + }; + configFile = mkOption { type = types.path; default = confFile; diff --git a/nixos/release.nix b/nixos/release.nix index 78448b5c9701..1e52c0f86a7a 100644 --- a/nixos/release.nix +++ b/nixos/release.nix @@ -248,6 +248,7 @@ in rec { tests.avahi = callTest tests/avahi.nix {}; tests.beegfs = callTest tests/beegfs.nix {}; tests.bittorrent = callTest tests/bittorrent.nix {}; + tests.bind = callTest tests/bind.nix {}; tests.blivet = callTest tests/blivet.nix {}; tests.boot = callSubTests tests/boot.nix {}; tests.boot-stage1 = callTest tests/boot-stage1.nix {}; diff --git a/nixos/tests/bind.nix b/nixos/tests/bind.nix new file mode 100644 index 000000000000..1f8c1dc7be40 --- /dev/null +++ b/nixos/tests/bind.nix @@ -0,0 +1,27 @@ +import ./make-test.nix { + name = "bind"; + + machine = { pkgs, lib, ... }: { + services.bind.enable = true; + services.bind.extraOptions = "empty-zones-enable no;"; + services.bind.zones = lib.singleton { + name = "."; + file = pkgs.writeText "root.zone" '' + $TTL 3600 + . IN SOA ns.example.org. admin.example.org. ( 1 3h 1h 1w 1d ) + . IN NS ns.example.org. + + ns.example.org. IN A 192.168.0.1 + ns.example.org. IN AAAA abcd::1 + + 1.0.168.192.in-addr.arpa IN PTR ns.example.org. + ''; + }; + }; + + testScript = '' + $machine->waitForUnit('bind.service'); + $machine->waitForOpenPort(53); + $machine->succeed('host 192.168.0.1 127.0.0.1 | grep -qF ns.example.org'); + ''; +}