46 lines
911 B
Nix
46 lines
911 B
Nix
{ lib, config, xml, ... }:
|
|
let
|
|
inherit (lib)
|
|
mkOption
|
|
mkEnableOption
|
|
mapAttrsToList
|
|
mkIf
|
|
mkMerge
|
|
;
|
|
inherit (lib.types)
|
|
attrsOf
|
|
submodule
|
|
;
|
|
|
|
interface-module =
|
|
{ name, config, ... }:
|
|
{
|
|
options = {
|
|
enable = mkEnableOption "the PoE for this interface";
|
|
xml = mkOption {
|
|
type = xml.type;
|
|
visible = false;
|
|
readOnly = true;
|
|
};
|
|
};
|
|
config.xml = mkMerge [
|
|
{ inherit name; }
|
|
(mkIf (!config.enable) { disable = { }; })
|
|
];
|
|
};
|
|
in
|
|
{
|
|
options = {
|
|
poe.interfaces = mkOption {
|
|
type = attrsOf (submodule interface-module);
|
|
default = { };
|
|
description = ''
|
|
PoE configuration of interfaces.
|
|
'';
|
|
};
|
|
};
|
|
config.netconf.xml.poe = {
|
|
"@operation" = "replace";
|
|
interface = mapAttrsToList (_: intf: intf.xml) config.poe.interfaces;
|
|
};
|
|
}
|