summaryrefslogtreecommitdiff
path: root/hosts/surtr/bifrost/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'hosts/surtr/bifrost/default.nix')
-rw-r--r--hosts/surtr/bifrost/default.nix66
1 files changed, 66 insertions, 0 deletions
diff --git a/hosts/surtr/bifrost/default.nix b/hosts/surtr/bifrost/default.nix
new file mode 100644
index 00000000..8f1e602d
--- /dev/null
+++ b/hosts/surtr/bifrost/default.nix
@@ -0,0 +1,66 @@
1{ config, lib, ... }:
2
3with lib;
4
5let
6 trim = str: if hasSuffix "\n" str then trim (removeSuffix "\n" str) else str;
7in {
8 config = {
9 systemd.network = {
10 netdevs = {
11 bifrost = {
12 netdevConfig = {
13 Name = "bifrost";
14 Kind = "wireguard";
15 };
16 wireguardConfig = {
17 PrivateKeyFile = config.sops.secrets.bifrost.path;
18 ListenPort = 51822;
19 };
20 wireguardPeers = [
21 { wireguardPeerConfig = {
22 AllowedIPs = [ "2a03:4000:52:ada:4:1::/96" ];
23 PublicKey = trim (readFile ../../vidhar/network/bifrost/vidhar.pub);
24 };
25 }
26 ];
27 };
28 };
29 networks = {
30 bifrost = {
31 name = "bifrost";
32 matchConfig = {
33 Name = "bifrost";
34 };
35 address = ["2a03:4000:52:ada:4::/96"];
36 routes = [
37 { routeConfig = {
38 Destination = "2a03:4000:52:ada:4::/80";
39 };
40 }
41 ];
42 linkConfig = {
43 RequiredForOnline = false;
44 };
45 networkConfig = {
46 LLMNR = false;
47 MulticastDNS = false;
48 };
49 };
50 };
51 };
52 sops.secrets.bifrost = {
53 format = "binary";
54 sopsFile = ./surtr.priv;
55 mode = "0640";
56 owner = "root";
57 group = "systemd-network";
58 };
59 environment.etc."systemd/networkd.conf" = {
60 text = ''
61 [Network]
62 RouteTable=bifrost:1026
63 '';
64 };
65 };
66}