diff options
| author | Christian <[email protected]> | 2026-06-30 21:09:31 -0500 |
|---|---|---|
| committer | Christian <[email protected]> | 2026-06-30 21:12:33 -0500 |
| commit | 2a7bdca90c3301b884a4f0452f48a07fbb4f19d7 (patch) | |
| tree | 606596004d502a7a1679b3db171e4497f37bf8f8 | |
| parent | b437572218d931eabb418e99740311e8e88c31f8 (diff) | |
Configurable wireguard module and separate ips for desktop and laptop
| -rw-r--r-- | hosts/desktop/configuration.nix | 2 | ||||
| -rw-r--r-- | hosts/laptop/configuration.nix | 2 | ||||
| -rw-r--r-- | modules/wireguard.nix | 52 |
3 files changed, 33 insertions, 23 deletions
diff --git a/hosts/desktop/configuration.nix b/hosts/desktop/configuration.nix index 5477d04..608af3e 100644 --- a/hosts/desktop/configuration.nix +++ b/hosts/desktop/configuration.nix @@ -24,6 +24,8 @@ boot.loader.efi.canTouchEfiVariables = false; boot.loader.efi.efiSysMountPoint = "/boot/efi"; + custom.wireguardAddress = "10.67.40.4/32"; + networking.hostName = "desktop"; networking.wireless.iwd.enable = true; networking.networkmanager.wifi.backend = "iwd"; diff --git a/hosts/laptop/configuration.nix b/hosts/laptop/configuration.nix index d37e424..51a175b 100644 --- a/hosts/laptop/configuration.nix +++ b/hosts/laptop/configuration.nix @@ -58,6 +58,8 @@ }; }; + custom.wireguardAddress = "10.67.40.2/32"; + home-manager.users.christian.custom.xmobarBattery = true; swapDevices = [ diff --git a/modules/wireguard.nix b/modules/wireguard.nix index 8df146d..3138a5f 100644 --- a/modules/wireguard.nix +++ b/modules/wireguard.nix @@ -6,31 +6,37 @@ }: { - # 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; - } - ]; + options.custom.wireguardAddress = lib.mkOption { + type = lib.types.str; }; - programs.bash.shellAliases = { - vpn-up = "sudo systemctl start wg-quick-wg0"; - vpn-down = "sudo systemctl stop wg-quick-wg0"; - }; + config = { + # 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 = [ config.custom.wireguardAddress ]; + privateKeyFile = "/etc/wireguard/wg0.key"; + peers = [ + { + publicKey = "wg37lctIxY4qbcyjVDrEI4mahH2Bhgv+73djEjJSyww="; + endpoint = "vpn.soltermann.xyz:51820"; + allowedIPs = [ "10.67.40.0/24" ]; + persistentKeepalive = 25; + } + ]; + }; - programs.fish.shellAliases = { - vpn-up = "sudo systemctl start wg-quick-wg0"; - vpn-down = "sudo systemctl stop wg-quick-wg0"; - }; + programs.bash.shellAliases = { + vpn-up = "sudo systemctl start wg-quick-wg0"; + vpn-down = "sudo systemctl stop wg-quick-wg0"; + }; - home-manager.users.christian.custom.xmobarVpn = true; + programs.fish.shellAliases = { + vpn-up = "sudo systemctl start wg-quick-wg0"; + vpn-down = "sudo systemctl stop wg-quick-wg0"; + }; + + home-manager.users.christian.custom.xmobarVpn = true; + }; } |
