39 lines
899 B
Nix
39 lines
899 B
Nix
{ 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 = ''
|
|
<interface><name>${name}</name>${optionalString (!config.enable) "<disable/>"}</interface>
|
|
'';
|
|
};
|
|
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 = ''
|
|
<poe operation="replace">
|
|
${
|
|
builtins.concatStringsSep "" (attrsets.mapAttrsToList (_: intf: intf.xml) config.poe.interfaces)
|
|
}
|
|
</poe>
|
|
'';
|
|
}
|