infrastructure/modules/netconf/dgn-profiles.nix
catvayor 15cec17611
feat(netconf/dgn-profiles): init
Module to factorise port configuration
2025-02-05 14:20:00 +01:00

53 lines
1 KiB
Nix

# SPDX-FileCopyrightText: 2025 Lubin Bailly <lubin.bailly@dgnum.eu>
#
# SPDX-License-Identifier: EUPL-1.2
{
options,
config,
lib,
...
}:
let
inherit (lib)
attrValues
genAttrs
mkMerge
mkOption
;
inherit (lib.types)
attrsOf
listOf
str
submodule
;
in
{
options.dgn-profiles = mkOption {
description = ''
Common configuration used on multiple interfaces.
'';
default = { };
type = attrsOf (submodule {
options = {
interfaces = mkOption {
description = ''
Interfaces on which this configuration apply
'';
type = listOf str;
};
configuration = mkOption {
description = ''
Configuration coresponding to this profile.
'';
type = options.dgn-interfaces.type.nestedTypes.elemType;
};
};
});
};
config.dgn-interfaces = mkMerge (
map ({ configuration, interfaces }: genAttrs interfaces (_: configuration)) (
attrValues config.dgn-profiles
)
);
}