diff --git a/modules/netconf/default.nix b/modules/netconf/default.nix index 81c54d1..9dfb290 100644 --- a/modules/netconf/default.nix +++ b/modules/netconf/default.nix @@ -9,5 +9,6 @@ ./dgn-hardware ./dgn-interfaces.nix ./dgn-access-control.nix + ./dgn-profiles.nix ]; } diff --git a/modules/netconf/dgn-profiles.nix b/modules/netconf/dgn-profiles.nix new file mode 100644 index 0000000..3d558ea --- /dev/null +++ b/modules/netconf/dgn-profiles.nix @@ -0,0 +1,53 @@ +# SPDX-FileCopyrightText: 2025 Lubin Bailly +# +# 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 + ) + ); +}