{ stdenv
, nettools
, openresolv
, name
, connect ? true
, ipConf ? {}
, useDNS ? true
}:

with stdenv.lib;

{
  "laeradhr" = {
    inherit name;
    debugLevel = 2;
    hosts = ( import ./hosts/laeradhr.nix );
    extraConfig = ''
      ${optionalString connect "ConnectTo = ymir"}
    '';
    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
        ${optionalString useDNS ''
        ${openresolv}/bin/resolvconf -m 0 -a tinc.laeradhr <<EOF
        domain yggdrasil
        nameserver 10.141.1.1
        EOF''}
      '';
      tinc-down = ''
        #!${stdenv.shell}
        ${optionalString useDNS ''
        ${openresolv}/bin/resolvconf -d tinc.laeradhr
        ''}
      '';
    };
    interfaceConfig = ipConf;
  };
}