From eed227bb4a8f5651dea126ab99ed1c10ae81cf97 Mon Sep 17 00:00:00 2001 From: ChUrl Date: Thu, 25 May 2023 00:06:09 +0200 Subject: [PATCH] Generate file with available vpn tunnels for rofi --- config/rofi/menus/servers.txt | 2 -- config/rofi/menus/vpn.fish | 8 ++++---- derivations/modules-options-doc/default.nix | 1 + system/modules/containers/default.nix | 1 + system/modules/systemd-networkd/default.nix | 6 ++++++ 5 files changed, 12 insertions(+), 6 deletions(-) delete mode 100644 config/rofi/menus/servers.txt diff --git a/config/rofi/menus/servers.txt b/config/rofi/menus/servers.txt deleted file mode 100644 index 3860b422..00000000 --- a/config/rofi/menus/servers.txt +++ /dev/null @@ -1,2 +0,0 @@ -de-115 -lu-16 \ No newline at end of file diff --git a/config/rofi/menus/vpn.fish b/config/rofi/menus/vpn.fish index 5a294287..561788ca 100755 --- a/config/rofi/menus/vpn.fish +++ b/config/rofi/menus/vpn.fish @@ -1,10 +1,10 @@ #!/usr/bin/env fish # User chooses VPN server, running servers are marked in green -set SERVERS (cat ~/NixFlake/config/rofi/menus/servers.txt) # TODO: This file should probably be generated by nix? +set SERVERS (cat /etc/rofi-vpns) # TODO: This file should probably be generated by nix? set PROMPT "" for SERVER in $SERVERS - set SERVER_RUNNING "$(systemctl list-units wg0-$SERVER.service | grep wg0-$SERVER.service)" + set SERVER_RUNNING "$(systemctl list-units $SERVER.service | grep $SERVER.service)" if test -z $SERVER_RUNNING set PROMPT $PROMPT$SERVER"\n" else @@ -25,7 +25,7 @@ if not contains $ACTION $ACTIONS end # Enable wireguard netdev -set COMMAND "systemctl $ACTION wg0-$SERVER.service" +set COMMAND "systemctl $ACTION $SERVER.service" set EVAL_RESULT "$(eval $COMMAND)" if test $ACTION = "status" && test -n "$EVAL_RESULT" @@ -36,5 +36,5 @@ else if test $ACTION = "start" # NOTE: With a shared home directory, firejail uses the same instance, so it won't work to # launch multiple browsers with different VPNs... # firejail --noprofile --allusers --private="~/.firejail-home" --netns="wg0-$SERVER" chromium --incognito --new-window ipaddress.my &>/dev/null - firejail --noprofile --private --netns="wg0-$SERVER" chromium --incognito --new-window ipaddress.my &>/dev/null + firejail --noprofile --private --netns="$SERVER" chromium --incognito --new-window ipaddress.my &>/dev/null end diff --git a/derivations/modules-options-doc/default.nix b/derivations/modules-options-doc/default.nix index 5d63df91..1f860c48 100644 --- a/derivations/modules-options-doc/default.nix +++ b/derivations/modules-options-doc/default.nix @@ -60,6 +60,7 @@ "nextcloud" "nnn" "ranger" + "rofi" "vscode" "waybar" ]; diff --git a/system/modules/containers/default.nix b/system/modules/containers/default.nix index daf8673a..b090d33c 100644 --- a/system/modules/containers/default.nix +++ b/system/modules/containers/default.nix @@ -1,3 +1,4 @@ +# TODO: Generate file with names for rofi { config, nixosConfig, diff --git a/system/modules/systemd-networkd/default.nix b/system/modules/systemd-networkd/default.nix index 4ad36bab..81c5370a 100644 --- a/system/modules/systemd-networkd/default.nix +++ b/system/modules/systemd-networkd/default.nix @@ -1,3 +1,4 @@ +# TODO: Generate file with VPN names for rofi # TODO: Need to set permissions through polkit module # TODO: Setup Wireless (IWD/Networkd?) { @@ -27,6 +28,11 @@ in { # Wireguard VPNs systemd.services = cfg.wireguard-tunnels; + environment.etc."rofi-vpns".text = let + names-list = attrNames cfg.wireguard-tunnels; + names = concatStringsSep "\n" names-list; + in + names; # General Networking Settings networking = {