summaryrefslogtreecommitdiff
path: root/modules/nycmesh.nix
blob: 70fbb6ed158060406c2f527a839aaf88c1887156 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
{ config, lib, pkgs, ... }:

let
  cfg = config.orbekk.nycmesh;
in
{
  options = {
    orbekk.nycmesh = {
      enable = lib.mkEnableOption "Enable VPN";

      listenPort = lib.mkOption {
        type = lib.types.port;
        default = 40423;
        description = "wireguard local port";
      };
    };
  };

  config = lib.mkIf cfg.enable {
    orbekk.simple-firewall.allowedUDPPorts = [ cfg.listenPort ];

    networking.wireguard = {
      enable = true;
      interfaces.nycmesh = {
        privateKeyFile = "/opt/secret/wireguard/nycmesh.private";
        ips = [ "10.70.73.50/32" ];
        allowedIPsAsRoutes = false;
        listenPort = cfg.listenPort;
        peers = [
          {
            endpoint = "wgvpn.sn1.mesh.nycmesh.net:51822";
            publicKey = "04crAKqAju+ZlEXCdZGAa4OyhDe1k2CHIlshr2KoYAQ=";
            allowedIPs = [ "0.0.0.0/0" "::0/0" ];
          }
        ];
      };
    };
  };
}