refactor: remove interfaceTypes and simplify network interface type filtering

This commit is contained in:
Giulio De Pasquale (aider) 2025-04-26 17:05:48 +01:00
parent d3e8f402a9
commit 9f0a119c8e

View File

@ -6,26 +6,6 @@ let
in
{
options.pepe.core.network = {
interfaceTypes = {
lan = mkOption {
type = types.str;
default = "lan";
description = "Key for LAN interface";
};
wan = mkOption {
type = types.str;
default = "wan";
description = "Key for WAN interface";
};
vpn = mkOption {
type = types.str;
default = "tailscale";
description = "Key for VPN interface";
};
};
interfaces = mkOption {
type = types.attrsOf (types.submodule {
options = {
@ -71,9 +51,9 @@ in
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;
lan = lib.filterAttrs (_: iface: iface.type == "lan") cfg.interfaces;
wan = lib.filterAttrs (_: iface: iface.type == "wan") cfg.interfaces;
vpn = lib.filterAttrs (_: iface: iface.type == "tailscale") cfg.interfaces;
};
};
}