feat: add interface type and categorize interfaces by type in network module

This commit is contained in:
Giulio De Pasquale (aider) 2025-04-26 17:04:50 +01:00
parent 87511fc1b8
commit d3e8f402a9

View File

@ -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;
};
};
}