summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--configs/wiregrill.nix13
1 files changed, 11 insertions, 2 deletions
diff --git a/configs/wiregrill.nix b/configs/wiregrill.nix
index d9e407d1..b8d23f49 100644
--- a/configs/wiregrill.nix
+++ b/configs/wiregrill.nix
@@ -3,6 +3,9 @@
enable = cfg.net != null;
net = config.krebs.build.host.nets.wiregrill or null;
};
+ # The hub is the host with a public address; the others reach each other
+ # through it.
+ isHub = cfg.net.via != null;
toCidrNotation = ip: "${ip.addr}/${toString ip.prefixLength}";
keyType = "application/x-wireguard-private-key";
keySlot = config.enstate.channels.secrets.slots."wiregrill.key";
@@ -33,7 +36,12 @@ in
allowedIPsAsRoutes = true;
peers = lib.mapAttrsToList
(_: host: {
- allowedIPs = host.nets.wiregrill.wireguard.subnets;
+ allowedIPs =
+ lib.optionals isHub (
+ lib.optional (host.nets.wiregrill.ip4 != null) host.nets.wiregrill.ip4.addr ++
+ lib.optional (host.nets.wiregrill.ip6 != null) host.nets.wiregrill.ip6.addr
+ ) ++
+ host.nets.wiregrill.wireguard.subnets;
endpoint =
lib.mkIf (host.nets.wiregrill.via != null) (host.nets.wiregrill.via.ip4.addr + ":${toString host.nets.wiregrill.wireguard.port}");
persistentKeepalive = lib.mkIf (host.nets.wiregrill.via != null) 61;
@@ -43,7 +51,8 @@ in
(lib.filterAttrs
(name: host:
name != config.krebs.build.host.name &&
- lib.hasAttr "wiregrill" host.nets)
+ lib.hasAttr "wiregrill" host.nets &&
+ (isHub || host.nets.wiregrill.via != null))
config.krebs.hosts);
};
systemd.network.networks.wiregrill = {
[cgit] Unable to lock slot /tmp/cgit/66000000.lock: Permission denied (13)