53 lines
1 KiB
Nix
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
|
|
)
|
|
);
|
|
}
|