51 lines
1 KiB
Nix
51 lines
1 KiB
Nix
{ lib, config, ... }:
|
|
let
|
|
inherit (lib)
|
|
mkOption
|
|
mkEnableOption
|
|
mapAttrsToList
|
|
optionalString
|
|
;
|
|
inherit (lib.types)
|
|
str
|
|
attrsOf
|
|
submodule
|
|
;
|
|
|
|
interface-module =
|
|
{ name, config, ... }:
|
|
{
|
|
options = {
|
|
enable = mkEnableOption "the PoE for this interface";
|
|
xml = mkOption {
|
|
type = str;
|
|
visible = false;
|
|
readOnly = true;
|
|
};
|
|
};
|
|
config.xml = ''
|
|
<interface><name>${name}</name>${optionalString (!config.enable) "<disable/>"}</interface>
|
|
'';
|
|
};
|
|
in
|
|
{
|
|
options = {
|
|
poe.interfaces = mkOption {
|
|
type = attrsOf (submodule interface-module);
|
|
default = { };
|
|
description = ''
|
|
PoE configuration of interfaces.
|
|
'';
|
|
};
|
|
netconf.xmls.poe = mkOption {
|
|
type = str;
|
|
visible = false;
|
|
readOnly = true;
|
|
};
|
|
};
|
|
config.netconf.xmls.poe = ''
|
|
<poe operation="replace">
|
|
${builtins.concatStringsSep "" (mapAttrsToList (_: intf: intf.xml) config.poe.interfaces)}
|
|
</poe>
|
|
'';
|
|
}
|