From 589841c265fa71fb42f9d489f05bf5db3182ee91 Mon Sep 17 00:00:00 2001 From: Lyn Date: Wed, 13 Nov 2024 21:01:13 +0100 Subject: [PATCH] comments, wgautomesh wrapper fix and removed unncessary logic --- hosts/network.nix | 11 +++++++++-- modules/services/wgautomesh.nix | 7 ++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/hosts/network.nix b/hosts/network.nix index 979d11c..24bfd13 100644 --- a/hosts/network.nix +++ b/hosts/network.nix @@ -5,13 +5,13 @@ }: let prefix = "lyn"; - #define wireguard subnets + #subnets routed through wireguard wg_subnets = { IPv4 = "10.35.0.1/24"; IPv6 = "fd1a:acab:cafe:1337::/64"; }; - #Below is where all hosts are defined + #hosts are defined here hosts = { wg-gateway = { wg = { @@ -126,9 +126,16 @@ in { }; }; }; + config = { ${prefix}.network = { 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"; + } + ]; }; } diff --git a/modules/services/wgautomesh.nix b/modules/services/wgautomesh.nix index 3bb154f..ab8190b 100644 --- a/modules/services/wgautomesh.nix +++ b/modules/services/wgautomesh.nix @@ -17,10 +17,7 @@ lib.mapAttrs (name: host: { pubkey = host.wg.pubkey; #if there is no public IP, make endpoint null so wgautomesh knows it unknown - endpoint = - if host.${version}.public == "" - then null - else host.${version}.public; + endpoint = host.${version}.public; address = host.${version}.internal; }) filteredHosts; @@ -47,7 +44,7 @@ in { }; services.wgautomesh = { enable = true; - services.wgautomesh.settings = { + settings = { interface = "wg0"; peers = if cfg.useIPv6