forked from DGNum/infrastructure
80 lines
1.8 KiB
Nix
80 lines
1.8 KiB
Nix
{ config, lib, ... }:
|
|
|
|
let
|
|
inherit (lib) mapAttrs mkOption;
|
|
|
|
inherit (lib.types)
|
|
attrsOf
|
|
bool
|
|
str
|
|
any
|
|
submodule
|
|
;
|
|
|
|
mandatory.options = {
|
|
supportPoE = mkOption {
|
|
type = bool;
|
|
example = true;
|
|
description = ''
|
|
Whether this interface supports PoE.
|
|
'';
|
|
};
|
|
};
|
|
in
|
|
{
|
|
imports = [
|
|
./interfaces.nix
|
|
./poe.nix
|
|
./protocols.nix
|
|
./system.nix
|
|
./vlans.nix
|
|
];
|
|
|
|
options = {
|
|
# Hack because of this https://git.dgnum.eu/DGNum/colmena/src/commit/71b1b660f2cda2e34e134d0028cafbd56bb22008/src/nix/hive/eval.nix#L166 which defines nixpkgs option but we don't have it here. What about liminix ?
|
|
nixpkgs = mkOption {
|
|
type = attrsOf any;
|
|
default = { };
|
|
};
|
|
netconf.xmls.configuration = mkOption {
|
|
type = str;
|
|
readOnly = true;
|
|
description = ''
|
|
The full configuration to send to a JunOS.
|
|
'';
|
|
};
|
|
netconf.mandatoryInterfaces = mkOption {
|
|
type = attrsOf (submodule mandatory);
|
|
example = {
|
|
"ge-0/0/0" = {
|
|
supportPoE = true;
|
|
};
|
|
"ge-0/0/1" = {
|
|
supportPoE = true;
|
|
};
|
|
"xe-0/0/0" = {
|
|
supportPoE = false;
|
|
};
|
|
};
|
|
description = ''
|
|
JunOS require some interfaces to always be configured (even if they are disabled),
|
|
which correspond to physical interfaces of the switch. They have to be declared here
|
|
with some information about it (only if it supports PoE for now).
|
|
'';
|
|
};
|
|
};
|
|
config.interfaces =
|
|
let
|
|
mkIntf = _: _: { };
|
|
in
|
|
mapAttrs mkIntf config.netconf.mandatoryInterfaces;
|
|
config.netconf.xmls.configuration = with config.netconf.xmls; ''
|
|
<configuration>
|
|
${system}
|
|
${interfaces}
|
|
${protocols}
|
|
${vlans}
|
|
${poe}
|
|
</configuration>
|
|
'';
|
|
}
|