summaryrefslogtreecommitdiff
path: root/sys/ns/ns.nix
blob: 4c242b609f3cb44bf1f8e279d2c8ee3aa1f90e9b (plain)
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
46
47
48
49
50
51
52
53
54
{ config, lib, ... }:
with lib; let
  inherit (config.local.ns.server) tsigName;
  inherit (config.local.nets) gate-public;
in
{
  options.local.ns.zones = mkOption {
    type = with lib.types; attrsOf (submodule ({ config, name, ... }:
      let
        cfg = config.localNS;
      in
      {
        options.localNS = {
          enable = mkEnableOption "local NS settings";

          primary = mkOption {
            type = str;
            default = "ns1";
          };
        };

        config = mkIf cfg.enable {
          # https://docs.gandi.net/en/domain_names/advanced_users/secondary_nameserver.html
          nsdConfig =
            let
              providerSecondary = [
                "37.205.15.45 ${tsigName}" # ns3.vpsfree.cz
                "37.205.11.85 ${tsigName}" # ns4.vpsfree.cz
                "2a03:3b40:fe:2be::1 ${tsigName}" # ns3.vpsfree.cz
                "2a03:3b40:101:4::1 ${tsigName}" # ns4.vpsfree.cz
              ];
            in
            {
              notify = providerSecondary;
              provideXFR = providerSecondary;
            };

          ns = [
            { name = "@"; host = cfg.primary; }
            { name = "@"; host = "ns3.vpsfree.cz."; }
            { name = "@"; host = "ns4.vpsfree.cz."; }
          ];

          a = [
            { name = cfg.primary; ipv4 = gate-public.hosts.gate.v4.address; }
          ];

          aaaa = [
            { name = cfg.primary; ipv6 = gate-public.hosts.gate.v6.address; }
          ];
        };
      }));
  };
}