git.iko.soy/typeable/nixpkgs
on master help sign in
nsd service: code cleanup

Puts everything in alphanumeric order and removes unnecessary spaces to better match NixOS coding style.

commit8442a7d12c399cc8bbe6cd6c4092b0df9f55dbac authorChristoph Hrdinka <c.github@hrdinka.at> dateTue 19 Jan 2016, 10:34 (11 years ago) parenta0753c7
1 file changed+393−385
nixos/modules/services/networking/nsd.nix+393−385
nixos/modules/services/networking/nsd.nix+393−385
@@ -7,14 +7,14 @@ let
77
88 username = "nsd";
99 stateDir = "/var/lib/nsd";
10− pidFile = stateDir + "/var/nsd.pid";
10+ pidFile = stateDir + "/var/nsd.pid";
1111
1212 nsdPkg = pkgs.nsd.override {
1313 bind8Stats = cfg.bind8Stats;
14− ipv6 = cfg.ipv6;
15− ratelimit = cfg.ratelimit.enable;
14+ ipv6 = cfg.ipv6;
15+ ratelimit = cfg.ratelimit.enable;
1616 rootServer = cfg.rootServer;
17− zoneStats = length (collect (x: (x.zoneStats or null) != null) cfg.zones) > 0;
17+ zoneStats = length (collect (x: (x.zoneStats or null) != null) cfg.zones) > 0;
1818 };
1919
2020 zoneFiles = pkgs.stdenv.mkDerivation {
@@ -30,59 +30,60 @@ let
3030 ];
3131 };
3232
33+ # options are ordered alphanumerically by the nixos option name
3334 configFile = pkgs.writeText "nsd.conf" ''
3435 server:
35− username: ${username}
3636 chroot: "${stateDir}"
37+ username: ${username}
3738
3839 # The directory for zonefile: files. The daemon chdirs here.
3940 zonesdir: "${stateDir}"
4041
4142 # the list of dynamically added zones.
42− zonelistfile: "${stateDir}/var/zone.list"
4343 database: "${stateDir}/var/nsd.db"
4444 pidfile: "${pidFile}"
4545 xfrdfile: "${stateDir}/var/xfrd.state"
4646 xfrdir: "${stateDir}/tmp"
47+ zonelistfile: "${stateDir}/var/zone.list"
4748
4849 # interfaces
4950 ${forEach " ip-address: " cfg.interfaces}
5051
51− server-count: ${toString cfg.serverCount}
52+ hide-version: ${yesOrNo cfg.hideVersion}
53+ identity: "${cfg.identity}"
5254 ip-transparent: ${yesOrNo cfg.ipTransparent}
5355 do-ip4: ${yesOrNo cfg.ipv4}
56+ ipv4-edns-size: ${toString cfg.ipv4EDNSSize}
5457 do-ip6: ${yesOrNo cfg.ipv6}
55− port: ${toString cfg.port}
56− verbosity: ${toString cfg.verbosity}
57− hide-version: ${yesOrNo cfg.hideVersion}
58− identity: "${cfg.identity}"
58+ ipv6-edns-size: ${toString cfg.ipv6EDNSSize}
5959 ${maybeString "nsid: " cfg.nsid}
60+ port: ${toString cfg.port}
61+ server-count: ${toString cfg.serverCount}
62+ ${if cfg.statistics == null then "" else "statistics: ${toString cfg.statistics}"}
6063 tcp-count: ${toString cfg.tcpCount}
6164 tcp-query-count: ${toString cfg.tcpQueryCount}
6265 tcp-timeout: ${toString cfg.tcpTimeout}
63− ipv4-edns-size: ${toString cfg.ipv4EDNSSize}
64− ipv6-edns-size: ${toString cfg.ipv6EDNSSize}
65− ${if cfg.statistics == null then "" else "statistics: ${toString cfg.statistics}"}
66+ verbosity: ${toString cfg.verbosity}
6667 xfrd-reload-timeout: ${toString cfg.xfrdReloadTimeout}
6768 zonefiles-check: ${yesOrNo cfg.zonefilesCheck}
6869
69− rrl-size: ${toString cfg.ratelimit.size}
70− rrl-ratelimit: ${toString cfg.ratelimit.ratelimit}
71− rrl-whitelist-ratelimit: ${toString cfg.ratelimit.whitelistRatelimit}
72− ${maybeString "rrl-slip: " cfg.ratelimit.slip}
7370 ${maybeString "rrl-ipv4-prefix-length: " cfg.ratelimit.ipv4PrefixLength}
7471 ${maybeString "rrl-ipv6-prefix-length: " cfg.ratelimit.ipv6PrefixLength}
72+ rrl-ratelimit: ${toString cfg.ratelimit.ratelimit}
73+ ${maybeString "rrl-slip: " cfg.ratelimit.slip}
74+ rrl-size: ${toString cfg.ratelimit.size}
75+ rrl-whitelist-ratelimit: ${toString cfg.ratelimit.whitelistRatelimit}
7576
7677 ${keyConfigFile}
7778
7879 remote-control:
7980 control-enable: ${yesOrNo cfg.remoteControl.enable}
81+ control-key-file: "${cfg.remoteControl.controlKeyFile}"
82+ control-cert-file: "${cfg.remoteControl.controlCertFile}"
8083 ${forEach " control-interface: " cfg.remoteControl.interfaces}
81− control-port: ${toString cfg.port}
84+ control-port: ${toString cfg.remoteControl.port}
8285 server-key-file: "${cfg.remoteControl.serverKeyFile}"
8386 server-cert-file: "${cfg.remoteControl.serverCertFile}"
84− control-key-file: "${cfg.remoteControl.controlKeyFile}"
85− control-cert-file: "${cfg.remoteControl.controlCertFile}"
8687
8788 # zone files reside in "${zoneFiles}" linked to "${stateDir}/zones"
8889 ${concatStrings (mapAttrsToList zoneConfigFile zoneConfigs)}
@@ -90,9 +91,9 @@ let
9091 ${cfg.extraConfig}
9192 '';
9293
93− yesOrNo = b: if b then "yes" else "no";
94+ yesOrNo = b: if b then "yes" else "no";
9495 maybeString = pre: s: if s == null then "" else ''${pre} "${s}"'';
95− forEach = pre: l: concatMapStrings (x: pre + x + "\n") l;
96+ forEach = pre: l: concatMapStrings (x: pre + x + "\n") l;
9697
9798
9899 keyConfigFile = concatStrings (mapAttrsToList (keyName: keyOptions: ''
@@ -111,17 +112,18 @@ let
111112 '') cfg.keys);
112113
113114
115+ # options are ordered alphanumerically by the nixos option name
114116 zoneConfigFile = name: zone: ''
115117 zone:
116118 name: "${name}"
117119 zonefile: "${stateDir}/zones/${name}"
118− ${maybeString "zonestats: " zone.zoneStats}
119120 ${maybeString "outgoing-interface: " zone.outgoingInterface}
120121 ${forEach " rrl-whitelist: " zone.rrlWhitelist}
122+ ${maybeString "zonestats: " zone.zoneStats}
121123
124+ allow-axfr-fallback: ${yesOrNo zone.allowAXFRFallback}
122125 ${forEach " allow-notify: " zone.allowNotify}
123126 ${forEach " request-xfr: " zone.requestXFR}
124− allow-axfr-fallback: ${yesOrNo zone.allowAXFRFallback}
125127
126128 ${forEach " notify: " zone.notify}
127129 notify-retry: ${toString zone.notifyRetry}
@@ -142,7 +144,7 @@ let
142144 );
143145
144146 # fighting infinite recursion
145− zoneOptions = zoneOptionsRaw // childConfig zoneOptions1 true;
147+ zoneOptions = zoneOptionsRaw // childConfig zoneOptions1 true;
146148 zoneOptions1 = zoneOptionsRaw // childConfig zoneOptions2 false;
147149 zoneOptions2 = zoneOptionsRaw // childConfig zoneOptions3 false;
148150 zoneOptions3 = zoneOptionsRaw // childConfig zoneOptions4 false;
@@ -152,26 +154,25 @@ let
152154
153155 childConfig = x: v: { options.children = { type = types.attrsOf x; visible = v; }; };
154156
157+ # options are ordered alphanumerically
155158 zoneOptionsRaw = types.submodule {
156159 options = {
157− children = mkOption {
158− default = {};
160+
161+ allowAXFRFallback = mkOption {
162+ type = types.bool;
163+ default = true;
159164 description = ''
160− Children zones inherit all options of their parents. Attributes
161− defined in a child will overwrite the ones of its parent. Only
162− leaf zones will be actually served. This way it's possible to
163− define maybe zones which share most attributes without
164− duplicating everything. This mechanism replaces nsd's patterns
165− in a save and functional way.
165+ If NSD as secondary server should be allowed to AXFR if the primary
166+ server does not allow IXFR.
166167 '';
167168 };
168169
169170 allowNotify = mkOption {
170− type = types.listOf types.str;
171− default = [ ];
172− example = [ "192.0.2.0/24 NOKEY" "10.0.0.1-10.0.0.5 my_tsig_key_name"
173− "10.0.3.4&255.255.0.0 BLOCKED"
174− ];
171+ type = types.listOf types.str;
172+ default = [ ];
173+ example = [ "192.0.2.0/24 NOKEY" "10.0.0.1-10.0.0.5 my_tsig_key_name"
174+ "10.0.3.4&255.255.0.0 BLOCKED"
175+ ];
175176 description = ''
176177 Listed primary servers are allowed to notify this secondary server.
177178 <screen><![CDATA[
@@ -193,28 +194,32 @@ let
193194 '';
194195 };
195196
196− requestXFR = mkOption {
197− type = types.listOf types.str;
198− default = [];
199− example = [];
197+ children = mkOption {
198+ default = {};
200199 description = ''
201− Format: <code>[AXFR|UDP] &lt;ip-address&gt; &lt;key-name | NOKEY&gt;</code>
200+ Children zones inherit all options of their parents. Attributes
201+ defined in a child will overwrite the ones of its parent. Only
202+ leaf zones will be actually served. This way it's possible to
203+ define maybe zones which share most attributes without
204+ duplicating everything. This mechanism replaces nsd's patterns
205+ in a save and functional way.
202206 '';
203207 };
204208
205− allowAXFRFallback = mkOption {
206− type = types.bool;
207− default = true;
209+ data = mkOption {
210+ type = types.str;
211+ default = "";
212+ example = "";
208213 description = ''
209− If NSD as secondary server should be allowed to AXFR if the primary
210− server does not allow IXFR.
214+ The actual zone data. This is the content of your zone file.
215+ Use imports or pkgs.lib.readFile if you don't want this data in your config file.
211216 '';
212217 };
213218
214219 notify = mkOption {
215− type = types.listOf types.str;
216− default = [];
217− example = [ "10.0.0.1@3721 my_key" "::5 NOKEY" ];
220+ type = types.listOf types.str;
221+ default = [];
222+ example = [ "10.0.0.1@3721 my_key" "::5 NOKEY" ];
218223 description = ''
219224 This primary server will notify all given secondary servers about
220225 zone changes.
@@ -231,38 +236,47 @@ let
231236 };
232237
233238 notifyRetry = mkOption {
234− type = types.int;
235− default = 5;
239+ type = types.int;
240+ default = 5;
236241 description = ''
237242 Specifies the number of retries for failed notifies. Set this along with notify.
238243 '';
239244 };
240245
246+ outgoingInterface = mkOption {
247+ type = types.nullOr types.str;
248+ default = null;
249+ example = "2000::1@1234";
250+ description = ''
251+ This address will be used for zone-transfere requests if configured
252+ as a secondary server or notifications in case of a primary server.
253+ Supply either a plain IPv4 or IPv6 address with an optional port
254+ number (ip@port).
255+ '';
256+ };
257+
241258 provideXFR = mkOption {
242− type = types.listOf types.str;
243− default = [];
244− example = [ "192.0.2.0/24 NOKEY" "192.0.2.0/24 my_tsig_key_name" ];
259+ type = types.listOf types.str;
260+ default = [];
261+ example = [ "192.0.2.0/24 NOKEY" "192.0.2.0/24 my_tsig_key_name" ];
245262 description = ''
246263 Allow these IPs and TSIG to transfer zones, addr TSIG|NOKEY|BLOCKED
247264 address range 192.0.2.0/24, 1.2.3.4&amp;255.255.0.0, 3.0.2.20-3.0.2.40
248265 '';
249266 };
250267
251− outgoingInterface = mkOption {
252− type = types.nullOr types.str;
253− default = null;
254− example = "2000::1@1234";
268+ requestXFR = mkOption {
269+ type = types.listOf types.str;
270+ default = [];
271+ example = [];
255272 description = ''
256− This address will be used for zone-transfere requests if configured
257− as a secondary server or notifications in case of a primary server.
258− Supply either a plain IPv4 or IPv6 address with an optional port
259− number (ip@port).
273+ Format: <code>[AXFR|UDP] &lt;ip-address&gt; &lt;key-name | NOKEY&gt;</code>
260274 '';
261275 };
262276
263277 rrlWhitelist = mkOption {
264− type = types.listOf types.str;
265− default = [];
278+ type = types.listOf types.str;
279+ default = [];
266280 description = ''
267281 Whitelists the given rrl-types.
268282 The RRL classification types are: nxdomain, error, referral, any,
@@ -270,20 +284,10 @@ let
270284 '';
271285 };
272286
273− data = mkOption {
274− type = types.str;
275− default = "";
276− example = "";
277− description = ''
278− The actual zone data. This is the content of your zone file.
279− Use imports or pkgs.lib.readFile if you don't want this data in your config file.
280− '';
281− };
282−
283287 zoneStats = mkOption {
284− type = types.nullOr types.str;
285− default = null;
286− example = "%s";
288+ type = types.nullOr types.str;
289+ default = null;
290+ example = "%s";
287291 description = ''
288292 When set to something distinct to null NSD is able to collect
289293 statistics per zone. All statistics of this zone(s) will be added
@@ -292,403 +296,407 @@ let
292296 and stats_noreset.
293297 '';
294298 };
299+
295300 };
296301 };
297302
298303in
299304{
300− options = {
301− services.nsd = {
305+ # options are ordered alphanumerically
306+ options.services.nsd = {
302307
303− enable = mkEnableOption "NSD authoritative DNS server";
304− bind8Stats = mkEnableOption "BIND8 like statistics";
308+ enable = mkEnableOption "NSD authoritative DNS server";
305309
306− rootServer = mkOption {
307− type = types.bool;
308− default = false;
309− description = ''
310− Wheter if this server will be a root server (a DNS root server, you
311− usually don't want that).
312− '';
313− };
310+ bind8Stats = mkEnableOption "BIND8 like statistics";
314311
315− interfaces = mkOption {
316− type = types.listOf types.str;
317− default = [ "127.0.0.0" "::1" ];
318− description = ''
319− What addresses the server should listen to.
320− '';
321− };
312+ extraConfig = mkOption {
313+ type = types.str;
314+ default = "";
315+ description = ''
316+ Extra nsd config.
317+ '';
318+ };
322319
323− serverCount = mkOption {
324− type = types.int;
325− default = 1;
326− description = ''
327− Number of NSD servers to fork. Put the number of CPUs to use here.
328− '';
329− };
320+ hideVersion = mkOption {
321+ type = types.bool;
322+ default = true;
323+ description = ''
324+ Wheter NSD should answer VERSION.BIND and VERSION.SERVER CHAOS class queries.
325+ '';
326+ };
330327
331− ipTransparent = mkOption {
332− type = types.bool;
333− default = false;
334− description = ''
335− Allow binding to non local addresses.
336− '';
337− };
328+ identity = mkOption {
329+ type = types.str;
330+ default = "unidentified server";
331+ description = ''
332+ Identify the server (CH TXT ID.SERVER entry).
333+ '';
334+ };
338335
339− ipv4 = mkOption {
340− type = types.bool;
341− default = true;
342− description = ''
343− Wheter to listen on IPv4 connections.
344− '';
345− };
336+ interfaces = mkOption {
337+ type = types.listOf types.str;
338+ default = [ "127.0.0.0" "::1" ];
339+ description = ''
340+ What addresses the server should listen to.
341+ '';
342+ };
346343
347− ipv6 = mkOption {
348− type = types.bool;
349− default = true;
350− description = ''
351− Wheter to listen on IPv6 connections.
352− '';
353− };
344+ ipTransparent = mkOption {
345+ type = types.bool;
346+ default = false;
347+ description = ''
348+ Allow binding to non local addresses.
349+ '';
350+ };
354351
355− port = mkOption {
356− type = types.int;
357− default = 53;
358− description = ''
359− Port the service should bind do.
360− '';
361− };
352+ ipv4 = mkOption {
353+ type = types.bool;
354+ default = true;
355+ description = ''
356+ Wheter to listen on IPv4 connections.
357+ '';
358+ };
362359
363− verbosity = mkOption {
364− type = types.int;
365− default = 0;
366− description = ''
367− Verbosity level.
368− '';
360+ ipv4EDNSSize = mkOption {
361+ type = types.int;
362+ default = 4096;
363+ description = ''
364+ Preferred EDNS buffer size for IPv4.
365+ '';
366+ };
367+
368+ ipv6 = mkOption {
369+ type = types.bool;
370+ default = true;
371+ description = ''
372+ Wheter to listen on IPv6 connections.
373+ '';
374+ };
375+
376+ ipv6EDNSSize = mkOption {
377+ type = types.int;
378+ default = 4096;
379+ description = ''
380+ Preferred EDNS buffer size for IPv6.
381+ '';
382+ };
383+
384+ nsid = mkOption {
385+ type = types.nullOr types.str;
386+ default = null;
387+ description = ''
388+ NSID identity (hex string, or "ascii_somestring").
389+ '';
390+ };
391+
392+ port = mkOption {
393+ type = types.int;
394+ default = 53;
395+ description = ''
396+ Port the service should bind do.
397+ '';
398+ };
399+
400+ rootServer = mkOption {
401+ type = types.bool;
402+ default = false;
403+ description = ''
404+ Wheter if this server will be a root server (a DNS root server, you
405+ usually don't want that).
406+ '';
407+ };
408+
409+ serverCount = mkOption {
410+ type = types.int;
411+ default = 1;
412+ description = ''
413+ Number of NSD servers to fork. Put the number of CPUs to use here.
414+ '';
415+ };
416+
417+ statistics = mkOption {
418+ type = types.nullOr types.int;
419+ default = null;
420+ description = ''
421+ Statistics are produced every number of seconds. Prints to log.
422+ If null no statistics are logged.
423+ '';
424+ };
425+
426+ tcpCount = mkOption {
427+ type = types.int;
428+ default = 100;
429+ description = ''
430+ Maximum number of concurrent TCP connections per server.
431+ '';
432+ };
433+
434+ tcpQueryCount = mkOption {
435+ type = types.int;
436+ default = 0;
437+ description = ''
438+ Maximum number of queries served on a single TCP connection.
439+ 0 means no maximum.
440+ '';
441+ };
442+
443+ tcpTimeout = mkOption {
444+ type = types.int;
445+ default = 120;
446+ description = ''
447+ TCP timeout in seconds.
448+ '';
449+ };
450+
451+ verbosity = mkOption {
452+ type = types.int;
453+ default = 0;
454+ description = ''
455+ Verbosity level.
456+ '';
457+ };
458+
459+ xfrdReloadTimeout = mkOption {
460+ type = types.int;
461+ default = 1;
462+ description = ''
463+ Number of seconds between reloads triggered by xfrd.
464+ '';
465+ };
466+
467+ zonefilesCheck = mkOption {
468+ type = types.bool;
469+ default = true;
470+ description = ''
471+ Wheter to check mtime of all zone files on start and sighup.
472+ '';
473+ };
474+
475+
476+ keys = mkOption {
477+ type = types.attrsOf (types.submodule {
478+ options = {
479+
480+ algorithm = mkOption {
481+ type = types.str;
482+ default = "hmac-sha256";
483+ description = ''
484+ Authentication algorithm for this key.
485+ '';
486+ };
487+
488+ keyFile = mkOption {
489+ type = types.path;
490+ description = ''
491+ Path to the file which contains the actual base64 encoded
492+ key. The key will be copied into "${stateDir}/private" before
493+ NSD starts. The copied file is only accessibly by the NSD
494+ user.
495+ '';
496+ };
497+
498+ };
499+ });
500+ default = {};
501+ example = {
502+ "tsig.example.org" = {
503+ algorithm = "hmac-md5";
504+ secret = "aaaaaabbbbbbccccccdddddd";
505+ };
369506 };
507+ description = ''
508+ Define your TSIG keys here.
509+ '';
510+ };
511+
512+
513+ ratelimit = {
370514
371− hideVersion = mkOption {
372− type = types.bool;
373− default = true;
515+ enable = mkEnableOption "ratelimit capabilities";
516+
517+ ipv4PrefixLength = mkOption {
518+ type = types.nullOr types.int;
519+ default = null;
374520 description = ''
375− Wheter NSD should answer VERSION.BIND and VERSION.SERVER CHAOS class queries.
521+ IPv4 prefix length. Addresses are grouped by netblock.
376522 '';
377523 };
378524
379− identity = mkOption {
380− type = types.str;
381− default = "unidentified server";
525+ ipv6PrefixLength = mkOption {
526+ type = types.nullOr types.int;
527+ default = null;
382528 description = ''
383− Identify the server (CH TXT ID.SERVER entry).
529+ IPv6 prefix length. Addresses are grouped by netblock.
384530 '';
385531 };
386532
387− nsid = mkOption {
388− type = types.nullOr types.str;
389− default = null;
533+ ratelimit = mkOption {
534+ type = types.int;
535+ default = 200;
390536 description = ''
391− NSID identity (hex string, or "ascii_somestring").
537+ Max qps allowed from any query source.
538+ 0 means unlimited. With an verbosity of 2 blocked and
539+ unblocked subnets will be logged.
392540 '';
393541 };
394542
395− tcpCount = mkOption {
396− type = types.int;
397− default = 100;
543+ slip = mkOption {
544+ type = types.nullOr types.int;
545+ default = null;
398546 description = ''
399− Maximum number of concurrent TCP connections per server.
547+ Number of packets that get discarded before replying a SLIP response.
548+ 0 disables SLIP responses. 1 will make every response a SLIP response.
400549 '';
401550 };
402551
403− tcpQueryCount = mkOption {
404− type = types.int;
405− default = 0;
552+ size = mkOption {
553+ type = types.int;
554+ default = 1000000;
406555 description = ''
407− Maximum number of queries served on a single TCP connection.
408− 0 means no maximum.
556+ Size of the hashtable. More buckets use more memory but lower
557+ the chance of hash hash collisions.
409558 '';
410559 };
411560
412− tcpTimeout = mkOption {
413− type = types.int;
414− default = 120;
561+ whitelistRatelimit = mkOption {
562+ type = types.int;
563+ default = 2000;
415564 description = ''
416− TCP timeout in seconds.
565+ Max qps allowed from whitelisted sources.
566+ 0 means unlimited. Set the rrl-whitelist option for specific
567+ queries to apply this limit instead of the default to them.
417568 '';
418569 };
419570
420− ipv4EDNSSize = mkOption {
421− type = types.int;
422− default = 4096;
571+ };
572+
573+
574+ remoteControl = {
575+
576+ enable = mkEnableOption "remote control via nsd-control";
577+
578+ controlCertFile = mkOption {
579+ type = types.path;
580+ default = "/etc/nsd/nsd_control.pem";
423581 description = ''
424− Preferred EDNS buffer size for IPv4.
582+ Path to the client certificate signed with the server certificate.
583+ This file is used by nsd-control and generated by nsd-control-setup.
425584 '';
426585 };
427586
428− ipv6EDNSSize = mkOption {
429− type = types.int;
430− default = 4096;
587+ controlKeyFile = mkOption {
588+ type = types.path;
589+ default = "/etc/nsd/nsd_control.key";
431590 description = ''
432− Preferred EDNS buffer size for IPv6.
591+ Path to the client private key, which is used by nsd-control
592+ but not by the server. This file is generated by nsd-control-setup.
433593 '';
434594 };
435595
436− statistics = mkOption {
437− type = types.nullOr types.int;
438− default = null;
596+ interfaces = mkOption {
597+ type = types.listOf types.str;
598+ default = [ "127.0.0.1" "::1" ];
439599 description = ''
440− Statistics are produced every number of seconds. Prints to log.
441− If null no statistics are logged.
600+ Which interfaces NSD should bind to for remote control.
442601 '';
443602 };
444603
445− xfrdReloadTimeout = mkOption {
446− type = types.int;
447− default = 1;
604+ port = mkOption {
605+ type = types.int;
606+ default = 8952;
448607 description = ''
449− Number of seconds between reloads triggered by xfrd.
608+ Port number for remote control operations (uses TLS over TCP).
450609 '';
451610 };
452611
453− zonefilesCheck = mkOption {
454− type = types.bool;
455− default = true;
612+ serverCertFile = mkOption {
613+ type = types.path;
614+ default = "/etc/nsd/nsd_server.pem";
456615 description = ''
457− Wheter to check mtime of all zone files on start and sighup.
616+ Path to the server self signed certificate, which is used by the server
617+ but and by nsd-control. This file is generated by nsd-control-setup.
458618 '';
459619 };
460620
461−
462− extraConfig = mkOption {
463− type = types.str;
464− default = "";
621+ serverKeyFile = mkOption {
622+ type = types.path;
623+ default = "/etc/nsd/nsd_server.key";
465624 description = ''
466− Extra nsd config.
625+ Path to the server private key, which is used by the server
626+ but not by nsd-control. This file is generated by nsd-control-setup.
467627 '';
468628 };
469629
470−
471− ratelimit = {
472− enable = mkEnableOption "ratelimit capabilities";
473−
474− size = mkOption {
475− type = types.int;
476− default = 1000000;
477− description = ''
478− Size of the hashtable. More buckets use more memory but lower
479− the chance of hash hash collisions.
480− '';
481− };
482−
483− ratelimit = mkOption {
484− type = types.int;
485− default = 200;
486− description = ''
487− Max qps allowed from any query source.
488− 0 means unlimited. With an verbosity of 2 blocked and
489− unblocked subnets will be logged.
490− '';
491− };
492−
493− whitelistRatelimit = mkOption {
494− type = types.int;
495− default = 2000;
496− description = ''
497− Max qps allowed from whitelisted sources.
498− 0 means unlimited. Set the rrl-whitelist option for specific
499− queries to apply this limit instead of the default to them.
500− '';
501− };
502−
503− slip = mkOption {
504− type = types.nullOr types.int;
505− default = null;
506− description = ''
507− Number of packets that get discarded before replying a SLIP response.
508− 0 disables SLIP responses. 1 will make every response a SLIP response.
509− '';
510− };
511−
512− ipv4PrefixLength = mkOption {
513− type = types.nullOr types.int;
514− default = null;
515− description = ''
516− IPv4 prefix length. Addresses are grouped by netblock.
517− '';
518− };
519−
520− ipv6PrefixLength = mkOption {
521− type = types.nullOr types.int;
522− default = null;
523− description = ''
524− IPv6 prefix length. Addresses are grouped by netblock.
525− '';
526− };
527− };
528−
529−
530− remoteControl = {
531− enable = mkEnableOption "remote control via nsd-control";
532−
533− interfaces = mkOption {
534− type = types.listOf types.str;
535− default = [ "127.0.0.1" "::1" ];
536− description = ''
537− Which interfaces NSD should bind to for remote control.
538− '';
539− };
540−
541− port = mkOption {
542− type = types.int;
543− default = 8952;
544− description = ''
545− Port number for remote control operations (uses TLS over TCP).
546− '';
547− };
548−
549− serverKeyFile = mkOption {
550− type = types.path;
551− default = "/etc/nsd/nsd_server.key";
552− description = ''
553− Path to the server private key, which is used by the server
554− but not by nsd-control. This file is generated by nsd-control-setup.
555− '';
556− };
557−
558− serverCertFile = mkOption {
559− type = types.path;
560− default = "/etc/nsd/nsd_server.pem";
561− description = ''
562− Path to the server self signed certificate, which is used by the server
563− but and by nsd-control. This file is generated by nsd-control-setup.
564− '';
565− };
566−
567− controlKeyFile = mkOption {
568− type = types.path;
569− default = "/etc/nsd/nsd_control.key";
570− description = ''
571− Path to the client private key, which is used by nsd-control
572− but not by the server. This file is generated by nsd-control-setup.
573− '';
574− };
575−
576− controlCertFile = mkOption {
577− type = types.path;
578− default = "/etc/nsd/nsd_control.pem";
579− description = ''
580− Path to the client certificate signed with the server certificate.
581− This file is used by nsd-control and generated by nsd-control-setup.
582− '';
583− };
584− };
630+ };
585631
586632
587− keys = mkOption {
588− type = types.attrsOf (types.submodule {
589− options = {
590− algorithm = mkOption {
591− type = types.str;
592− default = "hmac-sha256";
593− description = ''
594− Authentication algorithm for this key.
633+ zones = mkOption {
634+ type = types.attrsOf zoneOptions;
635+ default = {};
636+ example = {
637+ "serverGroup1" = {
638+ provideXFR = [ "10.1.2.3 NOKEY" ];
639+ children = {
640+ "example.com." = {
641+ data = ''
642+ $ORIGIN example.com.
643+ $TTL 86400
644+ @ IN SOA a.ns.example.com. admin.example.com. (
645+ ...
595646 '';
596647 };
597−
598− keyFile = mkOption {
599− type = types.path;
600− description = ''
601− Path to the file which contains the actual base64 encoded
602− key. The key will be copied into "${stateDir}/private" before
603− NSD starts. The copied file is only accessibly by the NSD
604− user.
648+ "example.org." = {
649+ data = ''
650+ $ORIGIN example.org.
651+ $TTL 86400
652+ @ IN SOA a.ns.example.com. admin.example.com. (
653+ ...
605654 '';
606655 };
607656 };
608− });
609− default = {};
610− example = {
611− "tsig.example.org" = {
612− algorithm = "hmac-md5";
613− secret = "aaaaaabbbbbbccccccdddddd";
614− };
615657 };
616− description = ''
617− Define your TSIG keys here.
618− '';
619− };
620−
621− zones = mkOption {
622− type = types.attrsOf zoneOptions;
623− default = {};
624− example = literalExample ''
625− { "serverGroup1" = {
626− provideXFR = [ "10.1.2.3 NOKEY" ];
627− children = {
628− "example.com." = {
629− data = '''
630− $ORIGIN example.com.
631− $TTL 86400
632− @ IN SOA a.ns.example.com. admin.example.com. (
633− ...
634− ''';
635− };
636− "example.org." = {
637− data = '''
638− $ORIGIN example.org.
639− $TTL 86400
640− @ IN SOA a.ns.example.com. admin.example.com. (
641− ...
642− ''';
643− };
644− };
645− };
646658
647− "example.net." = {
648− provideXFR = [ "10.3.2.1 NOKEY" ];
649− data = '''
650− ...
651− ''';
652− };
653− }
654− '';
655− description = ''
656− Define your zones here. Zones can cascade other zones and therefore
657− inherit settings from parent zones. Look at the definition of
658− children to learn about inheritance and child zones.
659− The given example will define 3 zones (example.(com|org|net).). Both
660− example.com. and example.org. inherit their configuration from
661− serverGroup1.
662− '';
659+ "example.net." = {
660+ provideXFR = [ "10.3.2.1 NOKEY" ];
661+ data = ''...'';
662+ };
663663 };
664−
664+ description = ''
665+ Define your zones here. Zones can cascade other zones and therefore
666+ inherit settings from parent zones. Look at the definition of
667+ children to learn about inheritance and child zones.
668+ The given example will define 3 zones (example.(com|org|net).). Both
669+ example.com. and example.org. inherit their configuration from
670+ serverGroup1.
671+ '';
665672 };
673+
666674 };
667675
668676 config = mkIf cfg.enable {
669677
670678 users.extraGroups = singleton {
671679 name = username;
672− gid = config.ids.gids.nsd;
680+ gid = config.ids.gids.nsd;
673681 };
674682
675683 users.extraUsers = singleton {
676− name = username;
684+ name = username;
677685 description = "NSD service user";
678− home = stateDir;
686+ home = stateDir;
679687 createHome = true;
680− uid = config.ids.uids.nsd;
681− group = username;
688+ uid = config.ids.uids.nsd;
689+ group = username;
682690 };
683691
684692 systemd.services.nsd = {
685693 description = "NSD authoritative only domain name service";
686− wantedBy = [ "multi-user.target" ];
687− after = [ "network.target" ];
694+ wantedBy = [ "multi-user.target" ];
695+ after = [ "network.target" ];
688696
689697 serviceConfig = {
690− PIDFile = pidFile;
691− Restart = "always";
698+ PIDFile = pidFile;
699+ Restart = "always";
692700 ExecStart = "${nsdPkg}/sbin/nsd -d -c ${configFile}";
693701 };
694702