ctucx.git: dns.nix

fork of https://github.com/kirelagin/dns.nix

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 
55 
56 
57 
58 
59 
60 
61 
62 
63 
64 
65 
66 
67 
#
# SPDX-FileCopyrightText: 2019 Kirill Elagin <https://kir.elagin.me/>
#
# SPDX-License-Identifier: MPL-2.0 or MIT
#

let
  dns = import ./.;
  util = dns.util.${builtins.currentSystem};

  testZone = with dns.lib.combinators; {
    SOA = {
      nameServer = "ns.test.com.";
      adminEmail = "admin@test.com";
      serial = 2019030800;
    };

    NS = [
      "ns.test.com."
      "ns2.test.com."
    ];

    A = [
      { address = "203.0.113.1"; ttl = 60 * 60; }
      "203.0.113.2"
      (ttl (60 * 60) (a "203.0.113.3"))
    ];

    AAAA = [
      "4321:0:1:2:3:4:567:89ab"
    ];

    MX = mx.google;

    TXT = [
      (with spf; strict ["a:mail.example.com" google])
    ];

    DMARC = [ (dmarc.postmarkapp "mailto:re+abcdefghijk@dmarc.postmarkapp.com") ];

    CAA = letsEncrypt "admin@example.com";

    SRV = [
      { service = "sip";
        proto = "tcp";
        port = 5060;
        target = "sip.example.com";
      }
    ];

    subdomains = rec {
      www.A = [ "203.0.113.4" ];
      www2 = host "203.0.113.5" "4321:0:1:2:3:4:567:89bb";
      www3 = host "203.0.113.6" null;
      www4 = www3;

      staging = delegateTo [
        "ns1.another.com."
        "ns2.another.com."
      ];

      foo.subdomains.www.CNAME = [ "foo.test.com." ];
    };
  };
in

util.writeZone "test.com" testZone