feat: add interfacesByType option to network module for type-based interface access

This commit is contained in:
Giulio De Pasquale (aider) 2025-04-26 17:09:33 +01:00
parent 2d4bdd0cfd
commit 894bc74667

View File

@ -46,11 +46,18 @@ in
default = { };
description = "An attribute set of networks with their configurations.";
};
interfacesByType = mkOption {
type = types.attrsOf (types.attrsOf types.anything);
default = {};
description = "Interfaces grouped by type (lan, wan, vpn) for easy access.";
internal = true;
};
};
config = {
# Create lists of interfaces by type for easy access elsewhere
cfg.interfacesByType = {
pepe.core.network.interfacesByType = {
lan = lib.filterAttrs (_: iface: iface.type == "lan") cfg.interfaces;
wan = lib.filterAttrs (_: iface: iface.type == "wan") cfg.interfaces;
vpn = lib.filterAttrs (_: iface: iface.type == "vpn") cfg.interfaces;