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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
{
machines,
config,
lib,
pkgs,
...
}:
let
inherit (lib) types;
cfg = config.zpha.configure.dnsServer;
in
{
options.zpha.configure.dnsServer = {
enable = lib.mkEnableOption "";
isPrimary = lib.mkOption {
type = types.bool;
default = config.networking.hostName == "cautus";
};
};
config = lib.mkIf cfg.enable (
let
allZones =
with pkgs.dnsNix.combinators;
let
TXT = [ "openpgp4fpr:BFE6386C8D66BCD4DAE14FC895F0FE7CD7E6A022" ];
CAA = [
{
issuerCritical = false;
tag = "issue";
value = "letsencrypt.org";
}
];
NS = [
"ns1.fc9f.de."
"ns2.fc9f.de."
];
SOA = {
nameServer = "ns1.fc9f.de.";
adminEmail = "dns@fc9f.de"; # Email address with a real `@`!
serial = 0;
};
in
{
"fc9f.de" = {
inherit NS SOA;
subdomains = {
acme.NS = [ "ns1" ];
ns1 = host machines.cautus.networking.ip4Address machines.cautus.networking.ip6Address;
ns2 = host machines.sorrah.networking.ip4Address machines.sorrah.networking.ip6Address;
};
};
"zaphyra.dn42" = {
NS = [ "ns1.zaphyra.dn42." ];
SOA = {
nameServer = "ns1.zaphyra.dn42.";
adminEmail = "dns@zaphyra.eu"; # Email address with a real `@`!
serial = 0;
};
subdomains = {
ns1.AAAA = [ "fd6b:6174:6a61:53::1" ];
ns2.AAAA = [ "fd6b:6174:6a61:53::2" ];
};
};
"zaphyra.eu" = {
inherit
SOA
NS
CAA
;
};
"zaphyra.de" = {
inherit
SOA
NS
CAA
TXT
;
};
"zpha.de" = {
inherit
SOA
NS
CAA
TXT
;
};
"katja.wtf" = {
inherit SOA NS CAA;
};
"ctucx.de" = {
inherit SOA NS CAA;
};
"thein.ovh" = {
inherit SOA NS CAA;
};
"ctu.cx" = {
inherit SOA NS CAA;
subdomains = {
_atproto.TXT = [ "did=did:plc:zaeuok3fmh2pcp4cjiicku4i" ];
};
};
};
in
{
systemd.services.knot.after = lib.mkIf cfg.isPrimary [ "sops-install-secrets.service" ];
sops.secrets.knotKeys = lib.mkIf cfg.isPrimary {
owner = "knot";
group = "knot";
};
dns = {
enable = true;
inherit allZones;
};
zpha.services = {
knot = {
enable = true;
primary = cfg.isPrimary;
zones = lib.mkIf cfg.isPrimary (
lib.mapAttrs (_name: value: {
file = value;
journal-content = "all";
zonefile-sync = -1;
zonefile-load = "difference-no-serial";
}) config.dns.zoneFiles
);
};
knotACME = lib.mkIf cfg.isPrimary {
enable = true;
zone = "acme.fc9f.de";
zones = lib.attrNames allZones;
nameServers = [
"ns1.fc9f.de."
];
keyFile = config.sops.secrets.knotKeys.path;
};
};
}
);
}