Nix configurations for my homelab
1{ pkgs, ... }:
2{
3 users.users.mou.packages = with pkgs; [
4 (writeShellScriptBin "ksu-vpn" ''
5 # Ask for sudo password before doing anything
6 sudo -v
7
8 # Get the cookie
9 cookie=$(${pkgs.gpauth}/bin/gpauth -q --default-browser vpn.kennesaw.edu)
10
11 # Connect to the vpn
12 printf '%s\n' "$cookie" | sudo ${pkgs.gpclient}/bin/gpclient connect vpn.kennesaw.edu \
13 --csd-wrapper ${pkgs.openconnect}/libexec/openconnect/hipreport.sh \
14 --cookie-on-stdin &
15
16 # I don't like this, but it doesn't seem like gpclient has a way to run scripts after a connection is established
17 # and I need to make sure that dns-over-tls is disabled for connections to work.
18 sleep 5
19 sudo resolvectl dnsovertls tun0 no
20
21 # Can either Ctrl + C to exit or run `sudo gpclient disconnect`
22 wait
23 '')
24 gpclient
25 ];
26}