feat(hakurei): exit

This commit is contained in:
arcnmx 2024-02-06 14:15:44 -08:00
parent 2039fd8cb6
commit 3c1d233b4e
3 changed files with 10 additions and 3 deletions

View file

@ -46,13 +46,19 @@ in {
fixResolved = optionalString config.services.resolved.enable '' fixResolved = optionalString config.services.resolved.enable ''
resolvectl revert ${config.services.tailscale.interfaceName} || true resolvectl revert ${config.services.tailscale.interfaceName} || true
''; '';
advertiseExitNode = optionalString cfg.advertiseExitNode " --advertise-exit-node"; # https://tailscale.com/kb/1320/performance-best-practices#ethtool-configuration
exitNodeRouting = optionalString cfg.advertiseExitNode ''
netdev=$(${pkgs.iproute2}/bin/ip route show 0/0 | ${pkgs.coreutils}/bin/cut -f5 -d' ' || echo eth0)
${getExe pkgs.ethtool} -K "$netdev" rx-udp-gro-forwarding on rx-gro-list off || true
'';
advertiseExitNode = "--advertise-exit-node" + optionalString (!cfg.advertiseExitNode) "=false";
in in
with pkgs; '' with pkgs; ''
# wait for tailscaled to settle # wait for tailscaled to settle
sleep 5 sleep 5
${fixResolved} ${fixResolved}
${exitNodeRouting}
# check if we are already authenticated to tailscale # check if we are already authenticated to tailscale
status="$(${getExe tailscale} status -json | ${getExe jq} -r .BackendState)" status="$(${getExe tailscale} status -json | ${getExe jq} -r .BackendState)"
@ -62,7 +68,7 @@ in {
fi fi
# otherwise authenticate with tailscale # otherwise authenticate with tailscale
${getExe tailscale} up${advertiseExitNode} -authkey $(cat ${config.sops.secrets.tailscale-key.path}) ${getExe tailscale} up ${advertiseExitNode} -authkey $(cat ${config.sops.secrets.tailscale-key.path})
''; '';
}; };
}; };

View file

@ -130,6 +130,8 @@ in {
}; };
}; };
services.tailscale.advertiseExitNode = true;
systemd.network.networks.eth0 = { systemd.network.networks.eth0 = {
name = "eth0"; name = "eth0";
matchConfig = { matchConfig = {

View file

@ -13,7 +13,6 @@
]; ];
services.kanidm.serverSettings.db_fs_type = "zfs"; services.kanidm.serverSettings.db_fs_type = "zfs";
services.tailscale.advertiseExitNode = true;
services.postgresql.package = pkgs.postgresql_14; services.postgresql.package = pkgs.postgresql_14;
sops.defaultSopsFile = ./secrets.yaml; sops.defaultSopsFile = ./secrets.yaml;