2024-04-03 19:55:30 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
config,
|
|
|
|
...
|
2024-08-18 22:22:59 +00:00
|
|
|
}: let
|
2024-04-03 19:55:30 +00:00
|
|
|
cfg = config.pub-solar.wireguard.pub-solar;
|
|
|
|
in {
|
|
|
|
options.pub-solar.wireguard.pub-solar = {
|
2024-06-17 13:23:32 +00:00
|
|
|
ownIPs = lib.mkOption {
|
2024-04-03 19:55:30 +00:00
|
|
|
description = "Internal ips in wireguard used for cluster control-plane communication.";
|
2024-06-17 13:23:32 +00:00
|
|
|
type = lib.types.listOf lib.types.str;
|
2024-04-03 19:55:30 +00:00
|
|
|
default = [];
|
|
|
|
};
|
|
|
|
|
2024-06-17 13:23:32 +00:00
|
|
|
privateKeyFile = lib.mkOption {
|
2024-04-03 19:55:30 +00:00
|
|
|
description = "Location of private key file";
|
2024-06-17 13:23:32 +00:00
|
|
|
type = lib.types.path;
|
2024-04-03 19:55:30 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-08-18 22:22:59 +00:00
|
|
|
config = lib.mkIf (lib.length cfg.ownIPs != 0) {
|
2024-04-03 19:55:30 +00:00
|
|
|
networking.firewall.allowedUDPPorts = [51821];
|
|
|
|
|
2024-08-18 22:22:59 +00:00
|
|
|
systemd.network.wait-online.ignoredInterfaces = ["wg-pub-solar"];
|
2024-04-15 10:39:13 +00:00
|
|
|
|
2024-06-17 13:23:32 +00:00
|
|
|
systemd.services.wireguard-wg-pub-solar = import ./service-override.nix lib;
|
2024-04-03 19:55:30 +00:00
|
|
|
|
|
|
|
networking.wireguard.interfaces = {
|
|
|
|
wg-pub-solar = {
|
|
|
|
listenPort = 51821;
|
|
|
|
mtu = 1300;
|
|
|
|
ips = cfg.ownIPs;
|
|
|
|
privateKeyFile = cfg.privateKeyFile;
|
|
|
|
peers = [
|
2024-04-06 00:35:51 +00:00
|
|
|
{
|
|
|
|
endpoint = "flora-6.pub.solar:51820";
|
2024-04-03 19:55:30 +00:00
|
|
|
publicKey = "jtSR5G2P/nm9s8WrVc26Xc/SQLupRxyXE+5eIeqlsTU=";
|
2024-08-18 22:22:59 +00:00
|
|
|
allowedIPs = ["10.7.6.2/32" "fd00:fae:fae:fae:fae:2::/96"];
|
2024-04-06 00:35:51 +00:00
|
|
|
persistentKeepalive = 15;
|
|
|
|
dynamicEndpointRefreshSeconds = 30;
|
2024-04-03 19:55:30 +00:00
|
|
|
}
|
2024-04-06 00:35:51 +00:00
|
|
|
{
|
2024-04-03 19:55:30 +00:00
|
|
|
endpoint = "nachtigall.pub.solar:51820";
|
|
|
|
publicKey = "qzNywKY9RvqTnDO8eLik75/SHveaSk9OObilDzv+xkk=";
|
2024-08-18 22:22:59 +00:00
|
|
|
allowedIPs = ["10.7.6.1/32" "fd00:fae:fae:fae:fae:1::/96"];
|
2024-04-06 00:35:51 +00:00
|
|
|
persistentKeepalive = 15;
|
|
|
|
dynamicEndpointRefreshSeconds = 30;
|
2024-04-03 19:55:30 +00:00
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|