~ruther/nixos-config

bff6a6140f6f285f6e8f0fda2f8a1b149117d72e — Rutherther 1 year, 6 months ago 36fc3b2
feat: add wireguard
2 files changed, 29 insertions(+), 0 deletions(-)

M modules/services/default.nix
A modules/services/wireguard.nix
M modules/services/default.nix => modules/services/default.nix +1 -0
@@ 12,6 12,7 @@

[
  ./syncthing.nix
  ./wireguard.nix
]

# redshift and media temporarely disables

A modules/services/wireguard.nix => modules/services/wireguard.nix +28 -0
@@ 0,0 1,28 @@
{ config, lib, pkgs, user, ... }:

{
  networking.firewall = {
    allowedUDPPorts = [ 51820 ];
  };

  networking.wireguard.interfaces = {
    wg0 = {
      ips = [ "192.168.32.50/32" ];
      listenPort = 51820;

      generatePrivateKeyFile = true;
      privateKeyFile = "/home/${user}/.config/wireguard/pk.pem";

      peers = [
        {
          publicKey = "Mui5wOV21QTer4NK2dUcBOgaW9UFzFzwmxOn/458ByI=";
          endpoint = "${inputs.semi-secrets.wg.serverEndpoint}";
            # The ip is not refreshed, as the kernel cannot perform DNS resolution. Use dynamicEndpointRefreshSeconds,
            # in case the ip is refreshed often. If not, sync after refresh should be alright.
          allowedIPs = [ "${inputs.semi-secrets.wg.allowedIp}" ];
          persistentKeepalive = 25;
        }
      ];
    };
  };
}

Do not follow this link