From 1ed3749c33d60411489d48adf700b71eccbd5b4a Mon Sep 17 00:00:00 2001 From: catvayor Date: Mon, 3 Feb 2025 16:24:31 +0100 Subject: [PATCH] feat(netconf/dgn-isp): init module to make isp switches description easier --- modules/netconf/default.nix | 1 + modules/netconf/dgn-isp.nix | 97 +++++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 modules/netconf/dgn-isp.nix diff --git a/modules/netconf/default.nix b/modules/netconf/default.nix index 9dfb290..e42a7d9 100644 --- a/modules/netconf/default.nix +++ b/modules/netconf/default.nix @@ -10,5 +10,6 @@ ./dgn-interfaces.nix ./dgn-access-control.nix ./dgn-profiles.nix + ./dgn-isp.nix ]; } diff --git a/modules/netconf/dgn-isp.nix b/modules/netconf/dgn-isp.nix new file mode 100644 index 0000000..93ba1f9 --- /dev/null +++ b/modules/netconf/dgn-isp.nix @@ -0,0 +1,97 @@ +# SPDX-FileCopyrightText: 2025 Lubin Bailly +# +# SPDX-License-Identifier: EUPL-1.2 + +{ + config, + lib, + ... +}: +let + inherit (lib) + mkEnableOption + mkIf + mkOption + ; + inherit (lib.types) + listOf + str + ; + cfg = config.dgn-isp; +in +{ + options.dgn-isp = { + enable = mkEnableOption "Common isp configuration"; + + AP = mkOption { + type = listOf str; + default = [ ]; + description = '' + Interfaces connected to one of our Access Point. + ''; + }; + + staging-AP = mkOption { + type = listOf str; + default = [ ]; + description = '' + Interfaces connected to one of our Access Point being deployed. + ''; + }; + + admin-ip = mkOption { + type = str; + description = '' + Administrative IPv6. + ''; + }; + }; + config = mkIf cfg.enable { + vlans = { + "uplink-cri".id = 223; + + "admin-core" = { + id = 3000; + l3-interface = "irb.0"; + }; + "admin-ap".id = 3001; + "users".id-list = [ + { + begin = 3045; + end = 4094; + } + ]; + + "ap-staging".id = 2000; + "hypervisor".id = 2001; + }; + + dgn-interfaces."irb".inet6.addresses = [ cfg.admin-ip ]; + + dgn-profiles = { + AP = { + interfaces = cfg.AP; + configuration = { + poe = true; + ethernet-switching = { + interface-mode = "trunk"; + vlans = [ + "users" + "admin-ap" + ]; + }; + }; + }; + staging-AP = { + interfaces = cfg.staging-AP; + configuration = { + poe = true; + ethernet-switching = { + interface-mode = "access"; + vlans = [ "ap-staging" ]; + }; + }; + }; + }; + }; +}