From 64915f75defe207019d22df007fe97c6220b0c87 Mon Sep 17 00:00:00 2001 From: catvayor Date: Sat, 31 Aug 2024 18:54:15 +0200 Subject: [PATCH] poe support --- junos/default.nix | 2 ++ junos/poe.nix | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 junos/poe.nix diff --git a/junos/default.nix b/junos/default.nix index a3e9d20..473d2a3 100644 --- a/junos/default.nix +++ b/junos/default.nix @@ -10,6 +10,7 @@ with lib; ./protocols.nix ./interfaces.nix ./vlans.nix + ./poe.nix ]; options = { netconf.xmls.configuration = mkOption { @@ -31,6 +32,7 @@ with lib; ${config.netconf.xmls.interfaces} ${config.netconf.xmls.protocols} ${config.netconf.xmls.vlans} + ${config.netconf.xmls.poe} ''; } diff --git a/junos/poe.nix b/junos/poe.nix new file mode 100644 index 0000000..550b6c1 --- /dev/null +++ b/junos/poe.nix @@ -0,0 +1,39 @@ +{ lib, config, ... }: +with lib; +let + interface-module = + { name, config, ... }: + { + options = { + enable = mkEnableOption "The PoE for interface ${name}."; + xml = mkOption { + type = types.str; + visible = false; + readOnly = true; + }; + }; + config.xml = '' + ${name}${optionalString (!config.enable) ""} + ''; + }; +in +{ + options = { + poe.interfaces = mkOption { + type = types.attrsOf (types.submodule interface-module); + default = { }; + }; + netconf.xmls.poe = mkOption { + type = types.str; + visible = false; + readOnly = true; + }; + }; + config.netconf.xmls.poe = '' + + ${ + builtins.concatStringsSep "" (attrsets.mapAttrsToList (_: intf: intf.xml) config.poe.interfaces) + } + + ''; +}