diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2015-11-04 13:40:18 +0100 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2015-11-04 13:40:18 +0100 |
commit | 7278996bf80f2712537f821fffc48fdec69d8478 (patch) | |
tree | f131ad6844393cd6bf93a6970f2e6f286f380157 /custom/tinc/yggdrasil.nix | |
parent | 89dbc12b798b562bc9e160eef7aba7b28d9b9920 (diff) | |
download | nixos-7278996bf80f2712537f821fffc48fdec69d8478.tar nixos-7278996bf80f2712537f821fffc48fdec69d8478.tar.gz nixos-7278996bf80f2712537f821fffc48fdec69d8478.tar.bz2 nixos-7278996bf80f2712537f821fffc48fdec69d8478.tar.xz nixos-7278996bf80f2712537f821fffc48fdec69d8478.zip |
tinc rewrite
Diffstat (limited to 'custom/tinc/yggdrasil.nix')
-rw-r--r-- | custom/tinc/yggdrasil.nix | 57 |
1 files changed, 30 insertions, 27 deletions
diff --git a/custom/tinc/yggdrasil.nix b/custom/tinc/yggdrasil.nix index 4c19e0e7..a4309278 100644 --- a/custom/tinc/yggdrasil.nix +++ b/custom/tinc/yggdrasil.nix | |||
@@ -1,30 +1,33 @@ | |||
1 | { config, pkgs, name, ip }: | 1 | { stdenv |
2 | , nettools | ||
3 | , openresolv | ||
4 | , connect ? true | ||
5 | , ipConf ? {} | ||
6 | } | ||
2 | 7 | ||
3 | { | ||
4 | config.services.tinc = { | ||
5 | networks = { | ||
6 | "yggdrasil" = { | ||
7 | name = name; | ||
8 | debugLevel = 2; | ||
9 | hosts = ( import ./yggdrasil-hosts.nix ); | ||
10 | extraConfig = "ConnectTo = surtr"; | ||
11 | scripts = { | ||
12 | tinc-up = '' | ||
13 | #!${pkgs.stdenv.shell} | ||
14 | ${pkgs.nettools}/bin/route add -net 10.141.1.0 netmask 255.255.255.0 gw 10.141.1.1 dev $INTERFACE metric 9999 | ||
15 | ${pkgs.openresolv}/bin/resolvconf -m 0 -a tinc.yggdrasil <<EOF | ||
16 | domain yggdrasil | ||
17 | nameserver 10.141.1.1 | ||
18 | EOF''; | ||
19 | tinc-down = '' | ||
20 | #!${pkgs.stdenv.shell} | ||
21 | ${pkgs.openresolv}/bin/resolvconf -d tinc.yggdrasil''; | ||
22 | }; | ||
23 | }; | ||
24 | }; | ||
25 | }; | ||
26 | 8 | ||
27 | config.networking.interfaces."tinc.yggdrasil" = { | 9 | let |
28 | useDHCP = false; | 10 | connectTo = if connect then "" else "ConnectTo = ymir" |
29 | } // ip; | 11 | { |
12 | "yggdrasil" = { | ||
13 | name = name; | ||
14 | debugLevel = 2; | ||
15 | hosts = ( import ./yggdrasil-hosts.nix ); | ||
16 | extraConfig = connectTo; | ||
17 | scripts = { | ||
18 | tinc-up = '' | ||
19 | #!${stdenv.shell} | ||
20 | ${nettools}/bin/route add -net 10.141.1.0 netmask 255.255.255.0 gw 10.141.1.1 dev $INTERFACE metric 9999 | ||
21 | ${openresolv}/bin/resolvconf -m 0 -a tinc.yggdrasil <<EOF | ||
22 | domain yggdrasil | ||
23 | nameserver 10.141.1.1 | ||
24 | EOF | ||
25 | ''; | ||
26 | tinc-down = '' | ||
27 | #!${stdenv.shell} | ||
28 | ${openresolv}/bin/resolvconf -d tinc.yggdrasil | ||
29 | ''; | ||
30 | }; | ||
31 | interfaceConfig = ipConf; | ||
32 | }; | ||
30 | } | 33 | } |