-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtopo.nix
85 lines (82 loc) · 2.29 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
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 "eth0";
};
}) ((builtins.attrNames (lib.filterAttrs (_: v: !v.nat) extraLibs.data.meta)) ++ [ "router" ])
))
// (lib.listToAttrs (
map (n: {
name = n;
value = {
interfaces = lib.concatMapAttrs (target: _: {
"wg-${target}" = {
virtual = true;
physicalConnections = [
{
node = target;
interface = "wg-${n}";
}
];
};
}) (extraLibs.conn { }).${n};
};
}) (builtins.attrNames extraLibs.data.meta)
))
// {
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";
};
}
)
];
};
}