summaryrefslogtreecommitdiff
path: root/modules/programs/wireguard/default.nix
blob: 8a0986e78779457809f7ae988efaa1c47c6fb4e3 (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
{ config, lib, pkgs, ... }:

{
  config = lib.mkIf config.system.enable {

    environment.systemPackages = with pkgs; [
      wireguard-tools
    ];

    # TODO: remove this!!!
    environment.etc = {
      "resolv.conf".text = "nameserver 10.1.1.1\n";
    };

    networking.wireguard.enable = true;
    networking.wireguard.interfaces = {
      freyanet = {
        ips = [ "10.2.0.2/32" "fd:cafe:dead:bee::2/128" "fe80::2/128" ];
        privateKeyFile = "${config.dotfilesPath}/secrets/freyanet.key";

        peers = [{
          publicKey = "x0ykwakpYCvI/pG+nR83lNUyeOE9m54thnX3bvZ+FUk=";
          allowedIPs = [ "10.0.0.0/12" "fd:cafe::/32" "fe80::/64" ];
          endpoint = "freya.cat:41111";
          persistentKeepalive = 25;
        }];
      };
    };

  };
}