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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
{
system = "x86_64-linux";
nixpkgsStable = true;
id = 2;
domain = "fc9f.de";
sshPublicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFfZ86/2bpfOY6G2pcEWPlmIS7Mf47lG+s+lmaD/ZL0Z";
wgPublicKey = "pLPU3QizJjY7QkCItenm/zRKKx5chCj5dTHBLtWHFQs=";
hardware = {
cpuVendor = "intel";
allowHibernation = false;
};
networking = {
ip4IsPrivate = false;
ip4Address = "91.132.144.50";
ip4PrefixLength = 22;
defaultGateway4 = "91.132.144.1";
ip6IsPrivate = false;
ip6Address = "2a03:4000:37:65f::1";
ip6PrefixLength = 64;
dn42 = {
ip6Address = "fd6b:6174:6a61::2";
ip6PrefixLength = 128;
};
};
nixosConfiguration =
{
machines,
machineConfig,
config,
lib,
...
}:
{
sops.secrets = {
wgPrivateKey = {
owner = "systemd-network";
group = "systemd-network";
};
};
common = {
profiles.netcup.enable = true;
configure = {
primaryNetworkInterface.enable = true;
rootDisk.swap = {
enable = true;
size = "2G";
};
};
};
zpha = {
configure = {
dnsServer.enable = true;
xmppServer.enable = true;
mailServer.enable = true;
matrixBridges.enable = true;
};
profiles = {
zaphyra.enable = true;
dn42 = {
enable = true;
addresses = [
"${machineConfig.networking.dn42.ip6Address}/${toString machineConfig.networking.dn42.ip6PrefixLength}"
"fd6b:6174:6a61:53::${toString machineConfig.id}/128"
];
};
};
websites = {
"zaphyra.eu".enable = true;
"oeffi.zaphyra.eu".enable = true;
"notes.zaphyra.eu".enable = true;
"dav.zaphyra.eu".enable = true;
"continuwuity.zaphyra.eu".enable = true;
"vault.zaphyra.eu".enable = true;
"git.zaphyra.eu".enable = true;
"bikemap.zaphyra.eu".enable = true;
"gts.zaphyra.eu".enable = true;
};
};
services.babeld = {
enable = true;
interfaces = {
wg-sorrah = { };
};
interfaceDefaults = {
type = "tunnel";
};
extraConfig = ''
local-port-readwrite 33123
export-table 254 # main
import-table 255 # local
kernel-priority 1000
# allow own prefixes
in ip fd6b:6174:6a61::/48 allow
# allow external routes
in ip fd00::/8 allow
in deny
redistribute ip fd6b:6174:6a61::${toString machineConfig.id} eq 48 allow
redistribute local deny
redistribute deny
'';
};
networking.firewall = {
checkReversePath = "loose";
trustedInterfaces = [ "wg-sorrah" ];
allowedUDPPorts = [
config.systemd.network.netdevs."42-wg-sorrah".wireguardConfig.ListenPort
];
};
systemd.network = {
config.networkConfig = {
IPv6Forwarding = true;
};
netdevs = {
"42-wg-sorrah" = {
netdevConfig = {
Kind = "wireguard";
Name = "wg-sorrah";
MTUBytes = 1280;
};
wireguardConfig = {
PrivateKeyFile = config.sops.secrets."wgPrivateKey".path;
ListenPort = 4200 + machineConfig.id;
FirewallMark = 4200 + machineConfig.id;
};
wireguardPeers = lib.singleton {
PublicKey = machines.sorrah.wgPublicKey;
AllowedIPs = lib.singleton "::/0";
Endpoint = "[${machines.sorrah.networking.ip6Address}]:${toString (4200 + machines.sorrah.id)}";
PersistentKeepalive = 10;
};
};
};
networks = {
"42-wg-sorrah" = {
matchConfig.Name = "wg-sorrah";
linkConfig = {
RequiredForOnline = false;
Multicast = true;
};
networkConfig = {
DHCP = false;
IPv6AcceptRA = false;
};
address = [
"fe80:fc9f::${toString machineConfig.id}/64"
"fd6b:6174:6a61:fc9f::${toString machineConfig.id}/48"
];
};
};
};
};
}