feat(netconf/dgn-profiles): init

Module to factorise port configuration
This commit is contained in:
catvayor 2025-02-03 16:07:44 +01:00
parent 902cce4edb
commit 15cec17611
Signed by: lbailly
GPG key ID: CE3E645251AC63F3
2 changed files with 54 additions and 0 deletions

View file

@ -9,5 +9,6 @@
./dgn-hardware
./dgn-interfaces.nix
./dgn-access-control.nix
./dgn-profiles.nix
];
}

View file

@ -0,0 +1,53 @@
# 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
)
);
}