about summary refs log tree commit diff stats
path: root/modules/by-name/dn/dns/module.nix
blob: 6611f8cd4da096c0cab684d7f49d6a0ce53c8724 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
{
  config,
  lib,
  ...
}: let
  cfg = config.vhack.dns;

  zones = lib.debug.traceValSeqN 2 (
    builtins.mapAttrs (name: value: {
      data =
        dns.types.zone.renderToString name value;
    })
    (lib.debug.traceValSeqN 4 cfg.zones)
  );

  dns = import ./dns {inherit lib;};
in {
  options.vhack.dns = {
    enable = lib.mkEnableOption "custom dns server";

    interfaces = lib.mkOption {
      type = lib.types.listOf lib.types.str;
      description = ''
        A list of the interfaces to bind to.
      '';
      example = [
        "192.168.1.3"
        "2001:db8:1::3"
      ];
    };

    zones = lib.mkOption {
      type = lib.types.attrsOf dns.types.zone.zone;
      description = "DNS zones";
    };
  };

  config = lib.mkIf cfg.enable {
    services.nsd = {
      enable = true;
      inherit (cfg) interfaces;
      inherit zones;
    };
  };
}