Skip to content

Instantly share code, notes, and snippets.

@grahamc

grahamc/ex.nix Secret

Created May 26, 2019 20:49
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save grahamc/d8a04839cf9d733df5927e82052fab0a to your computer and use it in GitHub Desktop.
{ pkgs, ... }:
{
networking.networkmanager.dispatcherScripts = [{
source = pkgs.writeScript "up-fix-wireguard" ''
#!/bin/sh
PATH=$PATH:${pkgs.wireguard}/bin
if [ "$2" != "up" ]; then
exit
fi
if [ "$CONNECTION_ID" = "LocalWifiNetwork" ]; then
echo "internal"
wg set wg0 peer PUBKEY endpoint INTERNAL:41741
else
echo "external"
wg set wg0 peer PUBKEY endpoint EXTERNAL:41741
fi
'';
}];
}
@zarelit
Copy link

zarelit commented Jul 2, 2019

I might find it useful, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment