mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-11-11 15:27:20 +03:00
94bc38e6c1
BIND doesn't allow the options section (or any section I'd guess) to be defined more than once, so whenever you want to set an additional option you're stuck using weird hacks like this: services.bind.forwarders = lib.mkForce [ "}; empty-zones-enable no; #" ]; This basically exploits the fact that values coming from the module options aren't escaped and thus works in a similar vain to how SQL injection works. Another option would be to just set configFile to a file that includes all the options, including zones. That obviously makes the configuration way less extensible and more awkward to use with the module system. To make sure this change does work correctly I added a small test just for that. The test could use some improvements, but better to have a test rather than none at all. For a future improvement the test could be merged with the NSD test, because both use the same zone file format. This change has been reviewed in #40053 and after not getting any opposition, I'm hereby adding this to master. Signed-off-by: aszlig <aszlig@nix.build> Cc: @peti, @edolstra Closes: #40053
28 lines
740 B
Nix
28 lines
740 B
Nix
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');
|
|
'';
|
|
}
|