-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtopo.nix
106 lines (103 loc) · 3.02 KB
/
topo.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
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
extraLibs:
{
...
}:
{
perSystem =
{
lib,
...
}:
{
topology.modules = [
(
{ config, ... }:
let
inherit (config.lib.topology)
mkInternet
mkConnection
mkRouter
;
in
{
renderers.elk.overviews = {
networks.enable = true;
services.enable = false;
};
nodes =
(lib.listToAttrs (
map
(n: {
name = "internet-${n}";
value = mkInternet {
connections = mkConnection n (if n == "kaambl" then "wlan0" else "eth0");
};
})
(
(builtins.attrNames (lib.filterAttrs (_: v: !v.nat) extraLibs.data.node))
++ [
"router"
"kaambl"
]
)
))
// (lib.listToAttrs (
map (n: {
name = n;
value = {
interfaces =
lib.concatMapAttrs
(target: _: {
"wg-${target}" = {
virtual = true;
physicalConnections = [
{
node = target;
interface = "wg-${n}";
}
];
};
})
(
lib.filterAttrs (
k: v:
if n == "kaambl" then
!extraLibs.data.node.${k}.nat
else if extraLibs.data.node.${n}.nat then
k != "kaambl"
else
true
) (extraLibs.conn { }).${n}
);
};
}) (builtins.attrNames extraLibs.data.node)
))
// {
router = mkRouter "MartinRouterKing" {
info = "home router";
interfaceGroups = [
[
"eth1"
"eth2"
"eth3"
]
[ "eth0" ]
];
connections.eth1 = mkConnection "hastur" "eth0";
connections.eth2 = mkConnection "eihort" "eth0";
# connections.eth3 = mkConnection "kaambl" "wlan0";
};
};
networks.wg-overlay = {
name = "wireguard overlay (babel)";
cidrv6 = "fdcc::0/64";
};
networks.nat = {
name = "NAT";
cidrv4 = "192.168.1.0/24";
};
}
)
];
};
}