From 5741324cb77d9b8948a0a558a191b7d372c70878 Mon Sep 17 00:00:00 2001 From: catvayor Date: Thu, 4 Apr 2024 18:17:36 +0200 Subject: [PATCH] static ip mgmt --- configMaker.nix | 2 +- moduleMaker.nix | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/configMaker.nix b/configMaker.nix index 4ab6644..601ac4a 100644 --- a/configMaker.nix +++ b/configMaker.nix @@ -29,7 +29,7 @@ let module_inst = { "me0" = { # mgmt enable = true; - management = true; + management = "192.168.42.6/24"; }; }; vlans = { diff --git a/moduleMaker.nix b/moduleMaker.nix index 538a311..9227414 100644 --- a/moduleMaker.nix +++ b/moduleMaker.nix @@ -29,8 +29,9 @@ in with lib; { default = false; }; management = mkOption { - type = types.bool; - default = false; + # FIXME : support ipv4 and ipv6, either static or dhcp (with the coffee) + type = types.nullOr types.str; + default = null; }; }; in builtins.listToAttrs (map (name: { inherit name; value = template name; }) interfaces); @@ -46,7 +47,12 @@ in with lib; { intf_xmlGen = name: let disable_flag = if !cfg.interfaces.${name}.enable then "" else ""; # FIXME : need to enforce address in reality - mgmt_fam = if cfg.interfaces.${name}.management then "" else ""; + mgmt_fam = if !builtins.isNull cfg.interfaces.${name}.management then '' + +
+ ${cfg.interfaces.${name}.management} +
+
'' else ""; members = map (vlan: "${builtins.toString vlan}") cfg.interfaces.${name}.vlans; eth_switch = if builtins.isNull cfg.interfaces.${name}.interface-mode then "" else '' @@ -68,7 +74,7 @@ in with lib; { interface_xmls = map intf_xmlGen interfaces; vlan_trust_table = let vlan_map = inter: vlan: - if builtins.isString vlan then + if builtins.isString vlan && cfg.interfaces.${inter}.enable then if cfg.interfaces.${inter}.dhcp_trusted then { ${vlan}.trust = inter; } else