Compare commits
6 Commits
d591feff45
...
762ea06406
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
762ea06406 | ||
|
|
51c4a1981c | ||
|
|
063acc40e2 | ||
|
|
b4d1086d57 | ||
|
|
040c0e2413 | ||
|
|
cd5fd3dffa |
@@ -36,7 +36,12 @@
|
|||||||
fsType = "vfat";
|
fsType = "vfat";
|
||||||
};
|
};
|
||||||
|
|
||||||
swapDevices = [ ];
|
swapDevices = [
|
||||||
|
{
|
||||||
|
device = "/swapfile";
|
||||||
|
size = 24 * 1024; # 24GB
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
|
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
|
||||||
# (the default) this is the recommended approach. When using systemd-networkd it's
|
# (the default) this is the recommended approach. When using systemd-networkd it's
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ in
|
|||||||
zsh.enable = true;
|
zsh.enable = true;
|
||||||
|
|
||||||
openvpn.enable = true;
|
openvpn.enable = true;
|
||||||
mullvad.enable = true;
|
|
||||||
|
|
||||||
c.enable = true;
|
c.enable = true;
|
||||||
go.enable = true;
|
go.enable = true;
|
||||||
|
|||||||
@@ -5,9 +5,6 @@
|
|||||||
[url "git@github.com:"]
|
[url "git@github.com:"]
|
||||||
insteadOf = https://github.com/
|
insteadOf = https://github.com/
|
||||||
|
|
||||||
[url "git@gitlab.com:"]
|
|
||||||
insteadOf = https://gitlab.com/
|
|
||||||
|
|
||||||
[url "git@codeberg.org:"]
|
[url "git@codeberg.org:"]
|
||||||
insteadOf = https://codeberg.org/
|
insteadOf = https://codeberg.org/
|
||||||
|
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
{
|
|
||||||
pkgs,
|
|
||||||
lib,
|
|
||||||
config,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
enabled = config.mod.mullvad.enable;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
options = {
|
|
||||||
mod.mullvad = {
|
|
||||||
enable = lib.mkEnableOption "enable mullvad module";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
config = lib.mkIf enabled {
|
|
||||||
services.mullvad-vpn = {
|
|
||||||
enable = true;
|
|
||||||
package = pkgs.mullvad-vpn;
|
|
||||||
};
|
|
||||||
|
|
||||||
age.secrets = {
|
|
||||||
"mullvad-device" = {
|
|
||||||
file = ../../../../secrets/pinwheel/mullvad-device.age;
|
|
||||||
path = "/etc/mullvad-vpn/device.json";
|
|
||||||
};
|
|
||||||
|
|
||||||
"mullvad-account-history" = {
|
|
||||||
file = ../../../../secrets/pinwheel/mullvad-account-history.age;
|
|
||||||
path = "/etc/mullvad-vpn/account-history.json";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -40,49 +40,47 @@ let
|
|||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
|
|
||||||
mullvad = pkgs.writeShellScript "mullvad" ''
|
tailscale = pkgs.writeShellScript "tailscale" ''
|
||||||
STATUS_DISCONNECTING="Disconnecting"
|
STATUS_STOPPED="Tailscale is stopped."
|
||||||
STATUS_DISCONNECTED="Disconnected"
|
|
||||||
STATUS_CONNECTING="Connecting"
|
|
||||||
STATUS_CONNECTED="Connected"
|
|
||||||
|
|
||||||
status() {
|
|
||||||
STATUS=$(${pkgs.mullvad}/bin/mullvad status | ${pkgs.gawk}/bin/awk 'NR==1{print $1}')
|
|
||||||
echo $STATUS
|
|
||||||
}
|
|
||||||
|
|
||||||
output() {
|
output() {
|
||||||
case $(status) in
|
STATUS=$(tailscale status)
|
||||||
$STATUS_DISCONNECTED)
|
|
||||||
echo '{ "text": "", "class": "disconnected" }' ;;
|
case $STATUS in
|
||||||
$STATUS_CONNECTING)
|
$STATUS_STOPPED)
|
||||||
echo '{ "text": "", "tooltip": "Connecting", "class": "disconnected" }' ;;
|
echo '{ "text": "", "class": "disconnected" }' ;;
|
||||||
$STATUS_CONNECTED)
|
|
||||||
TOOLTIP=$(${pkgs.mullvad}/bin/mullvad status | ${pkgs.gawk}/bin/awk 'NR==1')
|
|
||||||
echo "{ \"text\": \"\", \"tooltip\":\"$TOOLTIP\" }" ;;
|
|
||||||
$STATUS_DISCONNECTING)
|
|
||||||
echo '{ "text": "", "tooltip": "Disconnecting", "class": "disconnected" }' ;;
|
|
||||||
*)
|
*)
|
||||||
echo '{ "text": "", "tooltip": "Status unknown", "class": "disconnected" }' ;;
|
EXIT_NODE=$(tailscale status --json | ${pkgs.jq}/bin/jq .ExitNodeStatus)
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
toggle() {
|
EXIT_NODE_ONLINE=$(echo $EXIT_NODE | ${pkgs.jq}/bin/jq .Online)
|
||||||
CURRENT_STATUS=$(status)
|
if [ "$EXIT_NODE_ONLINE" == "null" ]; then
|
||||||
|
echo '{ "text": "", "class": "disconnected" }'
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
case "$CURRENT_STATUS" in
|
EXIT_NODE_ID=$(echo $EXIT_NODE | ${pkgs.jq}/bin/jq .ID)
|
||||||
$STATUS_DISCONNECTED)
|
EXIT_NODE_NAME=$(tailscale status --json | ${pkgs.jq}/bin/jq ".Peer.[] | select(.ID == $EXIT_NODE_ID) | .HostName")
|
||||||
${pkgs.mullvad}/bin/mullvad connect --wait > /dev/null && ${pkgs.libnotify}/bin/notify-send "Connected to VPN";;
|
echo "{ \"text\": \"\", \"tooltip\": $EXIT_NODE_NAME }"
|
||||||
$STATUS_CONNECTED)
|
;;
|
||||||
${pkgs.mullvad}/bin/mullvad disconnect --wait > /dev/null && ${pkgs.libnotify}/bin/notify-send "Disconnected from VPN";;
|
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toggle-exit-node() {
|
||||||
|
PREFERRED_EXIT_NODE=$(${pkgs.coreutils}/bin/cat ${config.age.secrets.tailscale-preferred-exit-node.path})
|
||||||
|
|
||||||
|
EXIT_NODE_ONLINE=$(tailscale status --json | ${pkgs.jq}/bin/jq .ExitNodeStatus.Online)
|
||||||
|
if [ "$EXIT_NODE_ONLINE" == "true" ]; then
|
||||||
|
tailscale set --exit-node="" && ${pkgs.libnotify}/bin/notify-send "Disconnected from Exit Node"
|
||||||
|
else
|
||||||
|
tailscale set --exit-node=$PREFERRED_EXIT_NODE && ${pkgs.libnotify}/bin/notify-send "Connected to Exit Node"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
case $1 in
|
case $1 in
|
||||||
--toggle)
|
--toggle-exit-node)
|
||||||
toggle ;;
|
toggle-exit-node ;;
|
||||||
--output)
|
--output)
|
||||||
output ;;
|
output ;;
|
||||||
esac
|
esac
|
||||||
'';
|
'';
|
||||||
|
|
||||||
@@ -131,9 +129,9 @@ in
|
|||||||
"custom/spotify"
|
"custom/spotify"
|
||||||
"custom/container-status"
|
"custom/container-status"
|
||||||
"custom/dunst"
|
"custom/dunst"
|
||||||
"custom/mullvad"
|
|
||||||
"bluetooth"
|
"bluetooth"
|
||||||
"wireplumber"
|
"wireplumber"
|
||||||
|
"custom/tailscale"
|
||||||
"network"
|
"network"
|
||||||
"battery"
|
"battery"
|
||||||
"clock"
|
"clock"
|
||||||
@@ -141,12 +139,12 @@ in
|
|||||||
|
|
||||||
"custom/work-vpn-status" = {
|
"custom/work-vpn-status" = {
|
||||||
exec = "${work-vpn-status}";
|
exec = "${work-vpn-status}";
|
||||||
interval = 1;
|
interval = 2;
|
||||||
};
|
};
|
||||||
|
|
||||||
"custom/spotify" = {
|
"custom/spotify" = {
|
||||||
exec = spotify-status;
|
exec = spotify-status;
|
||||||
interval = 1;
|
interval = 2;
|
||||||
max-length = 70;
|
max-length = 70;
|
||||||
tooltip = false;
|
tooltip = false;
|
||||||
};
|
};
|
||||||
@@ -154,21 +152,21 @@ in
|
|||||||
"custom/container-status" = {
|
"custom/container-status" = {
|
||||||
exec = "${container-status}";
|
exec = "${container-status}";
|
||||||
return-type = "json";
|
return-type = "json";
|
||||||
interval = 1;
|
interval = 2;
|
||||||
};
|
};
|
||||||
|
|
||||||
"custom/dunst" = {
|
"custom/dunst" = {
|
||||||
exec = notifications-status;
|
exec = notifications-status;
|
||||||
on-click-right = "${pkgs.dunst}/bin/dunstctl set-paused toggle";
|
on-click-right = "${pkgs.dunst}/bin/dunstctl set-paused toggle";
|
||||||
interval = 1;
|
interval = 2;
|
||||||
tooltip = false;
|
tooltip = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
"custom/mullvad" = {
|
"custom/tailscale" = {
|
||||||
exec = "${mullvad} --output";
|
exec = "${tailscale} --output";
|
||||||
return-type = "json";
|
return-type = "json";
|
||||||
on-click-right = "${mullvad} --toggle";
|
on-click-right = "${tailscale} --toggle-exit-node";
|
||||||
interval = 1;
|
interval = 2;
|
||||||
};
|
};
|
||||||
|
|
||||||
bluetooth = {
|
bluetooth = {
|
||||||
@@ -234,7 +232,7 @@ in
|
|||||||
|
|
||||||
"custom/work-vpn-status" = {
|
"custom/work-vpn-status" = {
|
||||||
exec = "${work-vpn-status}";
|
exec = "${work-vpn-status}";
|
||||||
interval = 1;
|
interval = 2;
|
||||||
};
|
};
|
||||||
|
|
||||||
"clock" = {
|
"clock" = {
|
||||||
@@ -279,7 +277,11 @@ in
|
|||||||
color: #${config.lib.colors.warning};
|
color: #${config.lib.colors.warning};
|
||||||
}
|
}
|
||||||
|
|
||||||
#custom-mullvad.disconnected {
|
#custom-tailscale {
|
||||||
|
font-size: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#custom-tailscale.disconnected {
|
||||||
color: #${config.lib.colors.warning};
|
color: #${config.lib.colors.warning};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -298,4 +300,12 @@ in
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
age.secrets = {
|
||||||
|
"tailscale-preferred-exit-node" = {
|
||||||
|
file = ../../../../secrets/pinwheel/tailscale-preferred-exit-node.age;
|
||||||
|
owner = "alex";
|
||||||
|
group = "users";
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
7
secrets/pinwheel/tailscale-preferred-exit-node.age
Normal file
7
secrets/pinwheel/tailscale-preferred-exit-node.age
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
age-encryption.org/v1
|
||||||
|
-> ssh-ed25519 vxPbZg Tzh50F+UxH7KF782cHBQXVg4nweNTZz+epW7FxRKd1o
|
||||||
|
msJg9fkg3eBfKCkFy01BLcMqZgOTN8UGRK15KTuLV1U
|
||||||
|
-> ssh-ed25519 +oNaHQ 66eLCU7O4ahGYnVAM5YwtICh7qRdyRiME/eDzUBzkXM
|
||||||
|
14tydJ+4YWV3HlWZmdae/2GHwTRgDUrWZHqYSFrXo/U
|
||||||
|
--- JT0KTZo3ZXYe7UEXQd1ge12/Vc+fSZWB7+tQiG7UYb4
|
||||||
|
<EFBFBD><EFBFBD>ojgo<67><6F>md'<27><><EFBFBD>42<34><32><EFBFBD><EFBFBD>-<2D>i<EFBFBD>B<03><>C[D<><44><EFBFBD>?P<>!w<>⺤<EFBFBD>p<EFBFBD>Ӂ,{<7B>hn|Pqf<71>
|
||||||
@@ -7,8 +7,7 @@ let
|
|||||||
in {
|
in {
|
||||||
"pinwheel/syncthing-cert.age".publicKeys = [ pinwheel alex ];
|
"pinwheel/syncthing-cert.age".publicKeys = [ pinwheel alex ];
|
||||||
"pinwheel/syncthing-key.age".publicKeys = [ pinwheel alex ];
|
"pinwheel/syncthing-key.age".publicKeys = [ pinwheel alex ];
|
||||||
"pinwheel/mullvad-device.age".publicKeys = [ pinwheel alex ];
|
"pinwheel/tailscale-preferred-exit-node.age".publicKeys = [ pinwheel alex ];
|
||||||
"pinwheel/mullvad-account-history.age".publicKeys = [ pinwheel alex ];
|
|
||||||
"pinwheel/alex.pinwheel-backwards.age".publicKeys = [ pinwheel alex ];
|
"pinwheel/alex.pinwheel-backwards.age".publicKeys = [ pinwheel alex ];
|
||||||
"pinwheel/alex.pinwheel-backwards.pub.age".publicKeys = [ pinwheel backwards alex ];
|
"pinwheel/alex.pinwheel-backwards.pub.age".publicKeys = [ pinwheel backwards alex ];
|
||||||
"pinwheel/alex.pinwheel-tadpole.age".publicKeys = [ pinwheel alex ];
|
"pinwheel/alex.pinwheel-tadpole.age".publicKeys = [ pinwheel alex ];
|
||||||
|
|||||||
Reference in New Issue
Block a user