diff options
| -rw-r--r-- | hosts/laptop/configuration.nix | 21 | ||||
| -rw-r--r-- | modules/home/christian.nix | 6 |
2 files changed, 26 insertions, 1 deletions
diff --git a/hosts/laptop/configuration.nix b/hosts/laptop/configuration.nix index 1bfa033..0c87cfe 100644 --- a/hosts/laptop/configuration.nix +++ b/hosts/laptop/configuration.nix @@ -37,11 +37,15 @@ programs.bash.shellAliases = { battery = "echo $(($(cat /sys/class/power_supply/BAT0/charge_now)*100/$(cat /sys/class/power_supply/BAT0/charge_full)))%"; hibernate = "systemctl hibernate"; + vpn-up = "sudo systemctl start wg-quick-wg0"; + vpn-down = "sudo systemctl stop wg-quick-wg0"; }; programs.fish.shellAliases = { battery = "echo (math (cat /sys/class/power_supply/BAT0/charge_now) * 100 / (cat /sys/class/power_supply/BAT0/charge_full))%"; hibernate = "systemctl hibernate"; + vpn-up = "sudo systemctl start wg-quick-wg0"; + vpn-down = "sudo systemctl stop wg-quick-wg0"; }; services.logind = { @@ -58,6 +62,23 @@ }; home-manager.users.christian.custom.xmobarBattery = true; + home-manager.users.christian.custom.xmobarVpn = true; + + # WireGuard — not started on boot, use `wg-quick up wg0` / `wg-quick down wg0` + # Private key must be placed at /etc/wireguard/wg0.key (mode 600, owned by root) + networking.wg-quick.interfaces.wg0 = { + autostart = false; + address = [ "10.67.40.2/32" ]; + privateKeyFile = "/etc/wireguard/wg0.key"; + peers = [ + { + publicKey = "wg37lctIxY4qbcyjVDrEI4mahH2Bhgv+73djEjJSyww="; + endpoint = "vpn.soltermann.xyz:51820"; + allowedIPs = [ "10.67.40.0/24" ]; + persistentKeepalive = 25; + } + ]; + }; swapDevices = [ { diff --git a/modules/home/christian.nix b/modules/home/christian.nix index 64403dc..377e8ef 100644 --- a/modules/home/christian.nix +++ b/modules/home/christian.nix @@ -9,6 +9,7 @@ imports = [ ./nvim ]; options.custom.xmobarBattery = lib.mkEnableOption "xmobar battery widget"; + options.custom.xmobarVpn = lib.mkEnableOption "xmobar VPN indicator"; config = { home.stateVersion = "25.11"; @@ -128,10 +129,13 @@ "-l", "red", "-m", "#4eb4fa", "-h", "green"] 600 ''} + ${lib.optionalString config.custom.xmobarVpn '' + , Run Com "sh" ["-c", "ip link show wg0 2>/dev/null | grep -q 'UP' && echo '<fc=green>vpn: on</fc>' || echo '<fc=red>vpn: off</fc>'"] "vpn" 30 + ''} ] , sepChar = "%" , alignSep = "}{" - , template = " %XMonadLog% | ${lib.optionalString config.custom.xmobarBattery "%battery% | "}%cpu% | %memory% | %wlan0% }{%date% " + , template = " %XMonadLog% | ${lib.optionalString config.custom.xmobarBattery "%battery% | "}${lib.optionalString config.custom.xmobarVpn "%vpn% | "}%cpu% | %memory% | %wlan0% }{%date% " } ''; }; |
