diff --git a/configMaker.nix b/configMaker.nix
index db938c3..ded07fe 100644
--- a/configMaker.nix
+++ b/configMaker.nix
@@ -35,7 +35,7 @@ let module_inst = {
vlans = {
"users".ids = [ { begin = 3045; end = 4094; } ];
"admin" = {
- ids = [ 3000 ];
+ ids = 3000;
management = "10.0.0.2/22";
};
"uplink-cri".ids = [ 223 ];
diff --git a/moduleMaker.nix b/moduleMaker.nix
index 643e39a..bc9f59e 100644
--- a/moduleMaker.nix
+++ b/moduleMaker.nix
@@ -10,7 +10,9 @@ in with lib; {
};
vlan_type.options = {
ids = mkOption {
- type = types.listOf (types.either types.ints.unsigned (types.submodule range_type));
+ type = types.either
+ types.ints.unsigned
+ (types.listOf (types.either types.ints.unsigned (types.submodule range_type)));
default = [ ];
};
management = mkOption {
@@ -65,7 +67,7 @@ in with lib; {
mgmt_fam = if !builtins.isNull cfg.interfaces.${name}.management then ''
- ${cfg.interfaces.${name}.management}
+ ${cfg.interfaces.${name}.management}
'' else "";
members = map (vlan: "${builtins.toString vlan}") cfg.interfaces.${name}.vlans;
@@ -73,6 +75,7 @@ in with lib; {
${cfg.interfaces.${name}.interface-mode}
${builtins.concatStringsSep "" members}
+ default
'';
in ''
@@ -85,8 +88,14 @@ in with lib; {
${eth_switch}
- '';
+
+ '';
interface_xmls = map intf_xmlGen interfaces;
+ rstp_gen = name:
+ if cfg.interfaces.${name}.enable && !builtins.isNull cfg.interfaces.${name}.interface-mode then
+ "${name}"
+ else "";
+ rstps = map rstp_gen interfaces;
vlan_trust_table = let
vlan_map = inter: vlan:
if builtins.isString vlan && cfg.interfaces.${inter}.enable then
@@ -109,7 +118,9 @@ in with lib; {
"${builtins.toString id.begin}-${builtins.toString id.end}";
in ''${list}'';
vlan_map = vlan: let
- ids = map id_map cfg.vlans.${vlan}.ids;
+ ids = if !builtins.isList cfg.vlans.${vlan}.ids then
+ [ "${builtins.toString cfg.vlans.${vlan}.ids}" ]
+ else map id_map cfg.vlans.${vlan}.ids;
mgmt_flag = if !builtins.isNull cfg.vlans.${vlan}.management
then "irb.0" else "";
in ''
@@ -137,11 +148,16 @@ in with lib; {
''
else "";
in [ ''
-
+
${builtins.concatStringsSep "\n" interface_xmls}
${irb_intf}
-
+
+
+ ${builtins.concatStringsSep "\n" rstps}
+
+
+
${builtins.concatStringsSep "\n" vlans}
'' vlan_trust_table
];