summaryrefslogtreecommitdiff
path: root/custom/tinc/laeradhr.nix
blob: abf309f0ff243645f8b455b503da7a4474cf6433 (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
31
32
33
34
35
{ stdenv
, nettools
, openresolv
, name
, connect ? true
, ipConf ? {}
, useDNS ? true
}:


let
  connectTo = if connect then "" else "ConnectTo = ymir";
in {
  "laeradhr" = {
    inherit name;
    debugLevel = 2;
    hosts = ( import ./hosts/laeradhr.nix );
    extraConfig = connectTo;
    scripts = {
      tinc-up = ''
        #!${stdenv.shell}
        ${nettools}/bin/route add -net 10.141.1.0 netmask 255.255.255.0 gw 10.141.1.1 dev $INTERFACE metric 9999
        ${if useDNS then ''${openresolv}/bin/resolvconf -m 0 -a tinc.laeradhr <<EOF
        domain yggdrasil
        nameserver 10.141.1.1
        EOF'' else ""}
      '';
      tinc-down = ''
        #!${stdenv.shell}
        ${openresolv}/bin/resolvconf -d tinc.laeradhr
      '';
    };
    interfaceConfig = ipConf;
  };
}