summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hosts/desktop/configuration.nix1
-rw-r--r--hosts/laptop/configuration.nix22
-rw-r--r--modules/wireguard.nix36
3 files changed, 38 insertions, 21 deletions
diff --git a/hosts/desktop/configuration.nix b/hosts/desktop/configuration.nix
index e63cc68..62a4147 100644
--- a/hosts/desktop/configuration.nix
+++ b/hosts/desktop/configuration.nix
@@ -14,6 +14,7 @@
../../modules/llm.nix
# ../../modules/local-llm.nix
../../modules/kvm.nix
+ ../../modules/wireguard.nix
];
boot.loader.grub = {
diff --git a/hosts/laptop/configuration.nix b/hosts/laptop/configuration.nix
index 0c87cfe..d37e424 100644
--- a/hosts/laptop/configuration.nix
+++ b/hosts/laptop/configuration.nix
@@ -12,6 +12,7 @@
./hardware-configuration.nix
../../modules/common.nix
../../modules/re.nix
+ ../../modules/wireguard.nix
];
boot.loader.grub = {
@@ -37,15 +38,11 @@
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 = {
@@ -62,23 +59,6 @@
};
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/wireguard.nix b/modules/wireguard.nix
new file mode 100644
index 0000000..8df146d
--- /dev/null
+++ b/modules/wireguard.nix
@@ -0,0 +1,36 @@
+{
+ config,
+ lib,
+ pkgs,
+ ...
+}:
+
+{
+ # 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;
+ }
+ ];
+ };
+
+ programs.bash.shellAliases = {
+ vpn-up = "sudo systemctl start wg-quick-wg0";
+ vpn-down = "sudo systemctl stop wg-quick-wg0";
+ };
+
+ 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;
+}