From a7adbd5063fe7ab428d8174cb9b31bec2c6133d6 Mon Sep 17 00:00:00 2001 From: yokai Date: Tue, 4 Aug 2026 17:05:42 -0500 Subject: common: parameterize LAN discovery interface Let the shared LAN discovery module use each host's Wi-Fi interface instead of assuming kusanagi's wlp8s0 everywhere. Set kusanagi to wlp8s0 and enzo to wlp1s0. Reuse the same setting for kusanagi's Ollama LAN firewall rule so the service opening stays tied to the declared LAN interface. Assisted-by: OpenAI:gpt-5 --- common/lan-discovery.nix | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) (limited to 'common') diff --git a/common/lan-discovery.nix b/common/lan-discovery.nix index f12971f..9341245 100644 --- a/common/lan-discovery.nix +++ b/common/lan-discovery.nix @@ -1,22 +1,36 @@ # LAN reachability and mDNS discovery shared by all machines. -{ ... }: +{ + config, + lib, + ... +}: +let + cfg = config.lanDiscovery; +in { - # Allow IPv4 ICMP echo requests so hosts can be found with ping. - networking.firewall.allowPing = true; + options.lanDiscovery.interface = lib.mkOption { + type = lib.types.str; + description = "Wi-Fi LAN interface used for mDNS discovery."; + }; + + config = { + # Allow IPv4 ICMP echo requests so hosts can be found with ping. + networking.firewall.allowPing = true; - # Avahi/mDNS: publish .local and resolve other *.local LAN names. - # Keep the multicast DNS firewall opening scoped to the Wi-Fi LAN interface. - networking.firewall.interfaces.wlp8s0.allowedUDPPorts = [ 5353 ]; - services.avahi = { - enable = true; - nssmdns4 = true; - openFirewall = false; - allowInterfaces = [ "wlp8s0" ]; - publish = { + # Avahi/mDNS: publish .local and resolve other *.local LAN names. + # Keep the multicast DNS firewall opening scoped to the host's Wi-Fi LAN interface. + networking.firewall.interfaces.${cfg.interface}.allowedUDPPorts = [ 5353 ]; + services.avahi = { enable = true; - addresses = true; - workstation = true; + nssmdns4 = true; + openFirewall = false; + allowInterfaces = [ cfg.interface ]; + publish = { + enable = true; + addresses = true; + workstation = true; + }; }; }; } -- cgit v1.3