summaryrefslogtreecommitdiff
path: root/system/vpn.nix
blob: c336f3213c52ab16d6a519773af878451f98b8f7 (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
{
  config,
  lib,
  pkgs,
  ...
}: let
  inherit (lib) mkIf;
  cfg = config.vpn;
in {
  config = mkIf cfg.enable {
    environment.systemPackages = with pkgs; [
      wireguard-tools
    ];

    networking.wg-quick.interfaces = {
      freyanet = {
        address = [cfg.ip];
        dns = ["10.2.0.1"];
        privateKeyFile = config.sops.secrets.freyanetWg.path;
        autostart = false;

        peers = [
          {
            publicKey = "x0ykwakpYCvI/pG+nR83lNUyeOE9m54thnX3bvZ+FUk=";
            allowedIPs = ["10.0.0.0/8"];
            endpoint = "freya.cat:3000";
            persistentKeepalive = 25;
          }
        ];
      };
    };

    sops = {
      enable = true;
      secrets.freyanetWg = {};
    };
  };
}