summaryrefslogtreecommitdiff
path: root/sys/ns/ns.nix
blob: f23fccf287f40f03bb80121b28e6eb59a66f7fb5 (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
{ config, lib, ... }:
with lib; let
  inherit (config.local.ns.server) tsigName;
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 = "37.205.12.147"; }
          ];

          aaaa = [
            { name = cfg.primary; ipv6 = "2a03:3b40:fe:3ec::1"; }
          ];
        };
      }));
  };
}