nix/os-mods/network/moz-nm-hook.fish.nix
Tristan Druyen dc8acd992a
Make MozillaVPN work with tailscale/netmaker/etc
- make a network manager hook template
- use for tailscale & netmaker
2024-01-23 01:11:11 +01:00

21 lines
734 B
Nix

{ pkgs
, vpn_interface
, vpn_network
, ...
}: (pkgs.writeText "${vpn_interface}-route" ''
#!${pkgs.fish}/bin/fish
set MOZ_INTERFACE "moz0"
set VPN_INTERFACE "${vpn_interface}"
set VPN_NETWORK "${vpn_network}"
sleep 1 # give mozillavpn time to create the rules we want to override
logger "NetworkManager dispatcher event: $argv[1], $argv[2]"
# When MOZ interface comes up, check and add the Tailscale route
if test "$argv[1]" = "$MOZ_INTERFACE" -a "$argv[2]" = "up"
# Re-creating forces high priority in case the route already exists
ip route del $VPN_NETWORK dev $VPN_INTERFACE
ip route add $VPN_NETWORK dev $VPN_INTERFACE
logger "Added Tailscale route for $VPN_NETWORK via $VPN_INTERFACE"
end
'')