summaryrefslogtreecommitdiff
path: root/hosts/surtr/bifrost/default.nix
blob: 790af94a7968d5adac0f57b7df5951bf5266cc72 (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
{ config, lib, ... }:

with lib;

let
  trim = str: if hasSuffix "\n" str then trim (removeSuffix "\n" str) else str;
in {
  config = {
    systemd.network = {
      netdevs = {
        bifrost = {
          netdevConfig = {
            Name = "bifrost";
            Kind = "wireguard";
          };
          wireguardConfig = {
            PrivateKeyFile = config.sops.secrets.bifrost.path;
            ListenPort = 51822;
          };
          wireguardPeers = [
            { wireguardPeerConfig = {
                AllowedIPs = [ "2a03:4000:52:ada:4:1::/96" ];
                PublicKey = trim (readFile ../../vidhar/network/bifrost/vidhar.pub);
              };
            }
          ];
        };
      };
      networks = {
        bifrost = {
          name = "bifrost";
          matchConfig = {
            Name = "bifrost";
          };
          address = ["2a03:4000:52:ada:4::/96"];
          routes = [
            { routeConfig = {
                Destination = "2a03:4000:52:ada:4::/80";
              };
            }
          ];
          linkConfig = {
            RequiredForOnline = false;
          };
          networkConfig = {
            LLMNR = false;
            MulticastDNS = false;
          };
        };
      };
    };
    sops.secrets.bifrost = {
      format = "binary";
      sopsFile = ./surtr.priv;
      mode = "0640";
      owner = "root";
      group = "systemd-network";
    };
  };
}