diff options
Diffstat (limited to 'common/tinc.nix')
-rw-r--r-- | common/tinc.nix | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/common/tinc.nix b/common/tinc.nix index 1016f42..d86b19c 100644 --- a/common/tinc.nix +++ b/common/tinc.nix | |||
@@ -7,12 +7,36 @@ let | |||
7 | in { | 7 | in { |
8 | imports = map (network: (./tinc/private + "/${network}")) networks; | 8 | imports = map (network: (./tinc/private + "/${network}")) networks; |
9 | 9 | ||
10 | services.tinc.networks = genAttrs networks (network: { | 10 | options.topology = { |
11 | name = config.networking.hostName; | 11 | mainVpn = { |
12 | interfaceName = mkOption { | ||
13 | type = types.str; | ||
14 | description = "Interface name of the main VPN"; | ||
15 | }; | ||
12 | 16 | ||
13 | hosts = let | 17 | subnet = mkOption { |
14 | hosts = attrNames (readDir (./tinc/private + "/${network}/hosts")); | 18 | type = types.str; |
15 | config = hostname: readFile (./tinc/private + "/${network}/hosts/${hostname}"); | 19 | description = "CIDR subnet of the main VPN"; |
16 | in genAttrs hosts config; | 20 | }; |
17 | }); | 21 | |
22 | currentNodeIP = mkOption { | ||
23 | type = types.str; | ||
24 | description = "The current node's IP address in the VPN"; | ||
25 | }; | ||
26 | }; | ||
27 | }; | ||
28 | |||
29 | config = { | ||
30 | services.tinc.networks = genAttrs networks (network: { | ||
31 | name = config.networking.hostName; | ||
32 | |||
33 | hosts = let | ||
34 | hosts = attrNames (readDir (./tinc/private + "/${network}/hosts")); | ||
35 | config = hostname: readFile (./tinc/private + "/${network}/hosts/${hostname}"); | ||
36 | in genAttrs hosts config; | ||
37 | }); | ||
38 | |||
39 | networking.firewall.allowedUDPPorts = [ 655 ]; | ||
40 | networking.firewall.allowedTCPPorts = [ 655 ]; | ||
41 | }; | ||
18 | } | 42 | } |