comments, wgautomesh wrapper fix and removed unncessary logic

This commit is contained in:
Lyn 2024-11-13 21:01:13 +01:00
parent 9080c75f6d
commit 589841c265
2 changed files with 11 additions and 7 deletions

View file

@ -5,13 +5,13 @@
}: let }: let
prefix = "lyn"; prefix = "lyn";
#define wireguard subnets #subnets routed through wireguard
wg_subnets = { wg_subnets = {
IPv4 = "10.35.0.1/24"; IPv4 = "10.35.0.1/24";
IPv6 = "fd1a:acab:cafe:1337::/64"; IPv6 = "fd1a:acab:cafe:1337::/64";
}; };
#Below is where all hosts are defined #hosts are defined here
hosts = { hosts = {
wg-gateway = { wg-gateway = {
wg = { wg = {
@ -126,9 +126,16 @@ in {
}; };
}; };
}; };
config = { config = {
${prefix}.network = { ${prefix}.network = {
inherit hosts wg_subnets; inherit hosts wg_subnets;
}; };
assertions = [
{
assertion = lib.any (host: host.v4 != null || host.v6 != null) (lib.attrValues hosts);
message = "At least one of v4 or v6 must be defined for each host";
}
];
}; };
} }

View file

@ -17,10 +17,7 @@
lib.mapAttrs (name: host: { lib.mapAttrs (name: host: {
pubkey = host.wg.pubkey; pubkey = host.wg.pubkey;
#if there is no public IP, make endpoint null so wgautomesh knows it unknown #if there is no public IP, make endpoint null so wgautomesh knows it unknown
endpoint = endpoint = host.${version}.public;
if host.${version}.public == ""
then null
else host.${version}.public;
address = host.${version}.internal; address = host.${version}.internal;
}) })
filteredHosts; filteredHosts;
@ -47,7 +44,7 @@ in {
}; };
services.wgautomesh = { services.wgautomesh = {
enable = true; enable = true;
services.wgautomesh.settings = { settings = {
interface = "wg0"; interface = "wg0";
peers = peers =
if cfg.useIPv6 if cfg.useIPv6