-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconsts.nix
56 lines (53 loc) · 1.45 KB
/
consts.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
{ lib, ... }:
{
wireguard =
let
port = 51820;
subnet = "192.168.33.";
in
rec {
hosts =
{
cloud = {
endPoint = "cloud.satanic.link";
pubKey = "6ndFmwbRoCQospT/7tiDW9vzGmPhnLwpLOBWG737V0M=";
ipAddress = 1;
};
yoga = {
ipAddress = 2;
pubKey = "mNoifcPcs9157BUNj0A5IkJVFJflffyaV2LbgcNjMWA=";
};
router = {
ipAddress = 3;
endPoint = "satanic.link";
pubKey = "SYHzYVpBDi8annhVGqvroQJLacRLTcmdDgQq4JlSDCs=";
};
};
makePeerConfig = excludedKey: lib.filter (x: x != null) (lib.attrsets.mapAttrsToList
(k: v:
if k == excludedKey then
null
else
let
basicConfig = {
PublicKey = v.pubKey;
AllowedIPs = [ "0.0.0.0/0" ];
PersistentKeepalive = 25;
};
endpointConfig = if v ? endPoint then { Endpoint = "${v.endPoint}:${toString port}"; } else { };
in
{
wireguardPeerConfig = lib.attrsets.recursiveUpdate basicConfig endpointConfig;
}
)
hosts);
getIpForHost = hostName:
let
hostEntry = hosts.${hostName} or null;
in
if hostEntry == null then
null
else
"${subnet}${toString hostEntry.ipAddress}/24";
};
}