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
{
inputs,
povSelf,
pkgs,
lib,
config,
hostConfig,
dnsNix,
...
}:
let
inherit (lib) types;
cfg = lib.getAttrFromPath povSelf config;
in
{
options = {
enable = {
type = types.bool;
default = false;
};
isPrimary = {
type = types.bool;
default = config.networking.hostName == "morio";
};
};
config = lib.mkIf cfg.enable (
let
allZones =
with dnsNix.combinators;
let
CAA = [
{
issuerCritical = false;
tag = "issue";
value = "letsencrypt.org";
}
];
NS = [
"morio.infra.zaphyra.eu."
"novus.infra.zaphyra.eu."
];
SOA = {
nameServer = "morio.infra.zaphyra.eu.";
adminEmail = "dns@zaphyra.eu"; # Email address with a real `@`!
serial = 0;
};
in
{
"zaphyra.eu" = {
inherit SOA NS CAA;
subdomains = {
"acme.infra".NS = [
"morio.infra.zaphyra.eu."
"novus.infra.zaphyra.eu."
];
"accesspoint.home.infra".AAAA = [ "2a03:4000:4d:5e:acab::2" ];
};
};
"zaphyra.de" = {
inherit SOA NS CAA;
};
"katja.wtf" = {
inherit SOA NS CAA;
subdomains = {
#legacy-stuff (zuggeschmack server)
"trabbi.infra".A = [ "94.16.104.148" ];
"trabbi.infra".AAAA = [ "2a03:4000:50:e8::1" ];
};
};
"ctu.cx" = {
inherit SOA NS CAA;
subdomains = {
ns1 = (
host inputs.self.hosts.morio.networking.ip4Address inputs.self.hosts.morio.networking.ip6Address
);
ns2 = (
host inputs.self.hosts.novus.networking.ip4Address inputs.self.hosts.novus.networking.ip6Address
);
_atproto.TXT = [ "did=did:plc:zaeuok3fmh2pcp4cjiicku4i" ];
};
};
"ctucx.de" = {
inherit SOA NS CAA;
};
"thein.ovh" = {
inherit SOA NS CAA;
};
"zuggeschmack.de" = {
inherit SOA NS CAA;
A = [ "94.16.104.148" ];
AAAA = [ "2a03:4000:50:e8::1" ];
subdomains.client.CNAME = [ "zuggeschmack.de." ];
};
};
in
{
systemd.services.knot.after = [ "sops-install-secrets.service" ];
sops.secrets.knotKeys = lib.mkIf cfg.isPrimary {
owner = "knot";
group = "knot";
};
dns = {
enable = true;
allZones = allZones;
};
modules.services = {
knot = {
enable = true;
primary = cfg.isPrimary;
zones = lib.mkIf cfg.isPrimary (
config.dns.zoneFiles
|> lib.mapAttrs (
name: value: {
file = value;
journal-content = "all";
zonefile-sync = -1;
zonefile-load = "difference-no-serial";
}
)
);
};
knotACME = lib.mkIf cfg.isPrimary {
enable = true;
zone = "acme.infra.zaphyra.eu";
zones = lib.attrNames allZones;
nameServers = [
"morio.infra.zaphyra.eu."
"novus.infra.zaphyra.eu."
];
keyFile = config.sops.secrets.knotKeys.path;
};
};
}
);
}