summaryrefslogtreecommitdiff
path: root/custom/tinc/yggdrasil.nix
blob: 4c19e0e719081c5f5df4f01244b0450babe74535 (plain)
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
{ config, pkgs, name, ip }:

{
  config.services.tinc = {
    networks = {
      "yggdrasil" = {
        name = name;
				debugLevel = 2;
				hosts = ( import ./yggdrasil-hosts.nix );
				extraConfig = "ConnectTo = surtr";
				scripts = {
				  tinc-up = ''
            #!${pkgs.stdenv.shell}
            ${pkgs.nettools}/bin/route add -net 10.141.1.0 netmask 255.255.255.0 gw 10.141.1.1 dev $INTERFACE metric 9999
            ${pkgs.openresolv}/bin/resolvconf -m 0 -a tinc.yggdrasil <<EOF
            domain yggdrasil
            nameserver 10.141.1.1
            EOF'';
					tinc-down = ''
						#!${pkgs.stdenv.shell}
            ${pkgs.openresolv}/bin/resolvconf -d tinc.yggdrasil'';
				};
			};
		};
	};

	config.networking.interfaces."tinc.yggdrasil" = {
    useDHCP = false;
	} // ip;
}