infrastructure/meta/isp/module.nix
Tom Hubrecht 92890e2228
All checks were successful
Check meta / check_dns (push) Successful in 15s
Check meta / check_dns (pull_request) Successful in 15s
Check meta / check_meta (pull_request) Successful in 15s
Check workflows / check_workflows (pull_request) Successful in 16s
Build all the nodes / netaccess01 (pull_request) Successful in 19s
Build all the nodes / netcore01 (pull_request) Successful in 19s
Check meta / check_meta (push) Successful in 28s
Build all the nodes / netcore02 (pull_request) Successful in 20s
Run pre-commit on all files / pre-commit (push) Successful in 55s
Build all the nodes / ap01 (pull_request) Successful in 1m9s
Build all the nodes / bridge01 (pull_request) Successful in 1m25s
Build the shell / build-shell (pull_request) Successful in 38s
Build all the nodes / hypervisor03 (pull_request) Successful in 1m32s
Build all the nodes / build01 (pull_request) Successful in 1m39s
Build all the nodes / hypervisor01 (pull_request) Successful in 1m43s
Build all the nodes / hypervisor02 (pull_request) Successful in 1m44s
Run pre-commit on all files / pre-commit (pull_request) Successful in 38s
Build all the nodes / rescue01 (pull_request) Successful in 1m35s
Build all the nodes / geo02 (pull_request) Successful in 1m51s
Build all the nodes / geo01 (pull_request) Successful in 1m51s
Build all the nodes / tower01 (pull_request) Successful in 1m36s
Build all the nodes / storage01 (pull_request) Successful in 1m46s
Build all the nodes / web03 (pull_request) Successful in 1m40s
Build all the nodes / web02 (pull_request) Successful in 1m48s
Build all the nodes / vault01 (pull_request) Successful in 1m55s
Build all the nodes / web01 (pull_request) Successful in 2m0s
Build all the nodes / compute01 (pull_request) Successful in 2m42s
feat(meta/isp): Init vlans
2025-03-02 18:00:46 +01:00

106 lines
2.7 KiB
Nix

# SPDX-FileCopyrightText: 2024 Tom Hubrecht <tom.hubrecht@dgnum.eu>
#
# SPDX-License-Identifier: EUPL-1.2
{ lib, ... }:
let
inherit (lib)
mkDefault
mkIf
mkOption
;
inherit (lib.types)
attrs
attrsOf
bool
ints
nullOr
submodule
str
;
in
{
options.isp = {
vlans = mkOption {
type = attrsOf (
submodule (
{ config, ... }:
{
options = {
id = mkOption {
type = ints.between 0 (4096 - 1);
description = ''
The VLAN id to use.
'';
};
settings = mkOption {
type = attrs;
default = { };
description = ''
Settings for the configuration of networkd.
'';
};
internal = {
network = mkOption {
type = nullOr str;
description = ''
The internal network address of this VLAN.
'';
};
prefix = mkOption {
type = nullOr (ints.between 0 32);
default = if config.userOnly then 27 else null;
description = ''
The prefix length of the network associated to this VLAN.
'';
};
address = mkOption {
type = nullOr str;
description = ''
The router address in the VLAN. It should be the first ipv4 in the network.
'';
};
cidr = mkOption {
type = nullOr str;
default =
with config.internal;
if (prefix != null && network != null) then "${network}/${builtins.toString prefix}" else null;
description = ''
The CIDR notation of the network associated to the VLAN.
'';
};
};
userOnly = mkOption {
type = bool;
default = false;
description = ''
Whether this VLAN is only used by a user in the context of the IPS.
I.e. this is not an administration VLAN.
'';
};
};
# The address is null by default when not on a user VLAN
config.internal = mkIf (!config.userOnly) {
address = mkDefault null;
network = mkDefault null;
};
}
)
);
default = [ ];
description = ''
The list of VLANs known to our ISP.
'';
};
};
}