From d3e8f402a96ad7f3bce116c42c083e5dd3c1f4fa Mon Sep 17 00:00:00 2001 From: "Giulio De Pasquale (aider)" Date: Sat, 26 Apr 2025 17:04:50 +0100 Subject: [PATCH] feat: add interface type and categorize interfaces by type in network module --- modules/core/network.nix | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/modules/core/network.nix b/modules/core/network.nix index 2a2246f..f44cfa7 100644 --- a/modules/core/network.nix +++ b/modules/core/network.nix @@ -34,6 +34,11 @@ in description = "The network interface name."; }; + type = mkOption { + type = types.enum [ "lan" "wan" "tailscale" ]; + description = "The type of interface (lan, wan, or vpn/tailscale)."; + }; + net = mkOption { type = types.str; description = "The network address in CIDR format."; @@ -62,4 +67,13 @@ in description = "An attribute set of networks with their configurations."; }; }; + + config = { + # Create lists of interfaces by type for easy access elsewhere + pepe.core.network.interfacesByType = { + lan = lib.filterAttrs (_: iface: iface.type == cfg.interfaceTypes.lan) cfg.interfaces; + wan = lib.filterAttrs (_: iface: iface.type == cfg.interfaceTypes.wan) cfg.interfaces; + vpn = lib.filterAttrs (_: iface: iface.type == cfg.interfaceTypes.vpn) cfg.interfaces; + }; + }; }