33 lines
823 B
Nix
33 lines
823 B
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
{
|
|
environment.systemPackages = with pkgs; [
|
|
wireguard-tools
|
|
];
|
|
|
|
# Enable WireGuard with WebSocket-optimized settings
|
|
networking.wireguard.interfaces = {
|
|
wg0 = {
|
|
# Generate with: wg genkey | tee privatekey | wg pubkey > publickey
|
|
privateKeyFile = "/etc/wireguard/privatekey";
|
|
|
|
ips = [ "10.0.0.2/24" ];
|
|
|
|
peers = [
|
|
{
|
|
publicKey = "R6uB4o5ELEKEHCvK+llRYbzdkZGDHegVmS0f08aRtWM=";
|
|
allowedIPs = [ "10.0.0.1/32" ];
|
|
endpoint = "170.75.161.21:51820";
|
|
persistentKeepalive = 15;
|
|
}
|
|
];
|
|
};
|
|
};
|
|
|
|
# Systemd service optimization for WireGuard
|
|
systemd.services."wireguard-wg0".serviceConfig = {
|
|
# Restart the service if it fails
|
|
Restart = "on-failure";
|
|
RestartSec = "5s";
|
|
};
|
|
}
|