forked from DGNum/infrastructure
feat(netconf/dgn-profiles): init
Module to factorise port configuration
This commit is contained in:
parent
902cce4edb
commit
15cec17611
2 changed files with 54 additions and 0 deletions
|
@ -9,5 +9,6 @@
|
||||||
./dgn-hardware
|
./dgn-hardware
|
||||||
./dgn-interfaces.nix
|
./dgn-interfaces.nix
|
||||||
./dgn-access-control.nix
|
./dgn-access-control.nix
|
||||||
|
./dgn-profiles.nix
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
53
modules/netconf/dgn-profiles.nix
Normal file
53
modules/netconf/dgn-profiles.nix
Normal 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
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue