2025-02-19 16:49:58 +07:00
|
|
|
{ lib, ... }:
|
|
|
|
let
|
|
|
|
inherit (lib) types mkOption;
|
|
|
|
|
|
|
|
inherit (types)
|
|
|
|
# attrsOf uses attrsWith internally
|
|
|
|
attrsOf
|
|
|
|
listOf
|
2025-01-19 16:07:39 +01:00
|
|
|
unique
|
2025-01-19 16:21:33 +01:00
|
|
|
nullOr
|
2025-01-19 16:22:24 +01:00
|
|
|
functionTo
|
2025-01-19 16:24:43 +01:00
|
|
|
coercedTo
|
2025-01-19 16:39:44 +01:00
|
|
|
either
|
2025-02-19 16:49:58 +07:00
|
|
|
;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
imports = [
|
|
|
|
# Module A
|
|
|
|
(
|
|
|
|
{ ... }:
|
|
|
|
{
|
|
|
|
options.attrsWith = mkOption {
|
|
|
|
type = attrsOf (listOf types.str);
|
|
|
|
};
|
|
|
|
options.mergedAttrsWith = mkOption {
|
|
|
|
type = attrsOf (listOf types.str);
|
|
|
|
};
|
|
|
|
options.listOf = mkOption {
|
|
|
|
type = listOf (listOf types.str);
|
|
|
|
};
|
|
|
|
options.mergedListOf = mkOption {
|
|
|
|
type = listOf (listOf types.str);
|
|
|
|
};
|
2025-01-19 16:07:39 +01:00
|
|
|
# unique
|
|
|
|
options.unique = mkOption {
|
|
|
|
type = unique { message = ""; } (listOf types.str);
|
|
|
|
};
|
|
|
|
options.mergedUnique = mkOption {
|
|
|
|
type = unique { message = ""; } (listOf types.str);
|
|
|
|
};
|
2025-01-19 16:21:33 +01:00
|
|
|
# nullOr
|
|
|
|
options.nullOr = mkOption {
|
|
|
|
type = nullOr (listOf types.str);
|
|
|
|
};
|
|
|
|
options.mergedNullOr = mkOption {
|
|
|
|
type = nullOr (listOf types.str);
|
|
|
|
};
|
2025-01-19 16:24:43 +01:00
|
|
|
# functionTo
|
2025-01-19 16:22:24 +01:00
|
|
|
options.functionTo = mkOption {
|
|
|
|
type = functionTo (listOf types.str);
|
|
|
|
};
|
|
|
|
options.mergedFunctionTo = mkOption {
|
|
|
|
type = functionTo (listOf types.str);
|
|
|
|
};
|
2025-01-19 16:24:43 +01:00
|
|
|
# coercedTo
|
|
|
|
# Note: coercedTo is a non-mergeable option-type
|
|
|
|
options.coercedTo = mkOption {
|
|
|
|
type = coercedTo (listOf types.str) lib.id (listOf types.str);
|
|
|
|
};
|
2025-01-19 16:39:44 +01:00
|
|
|
options.either = mkOption {
|
|
|
|
type = either (listOf types.str) (listOf types.str);
|
|
|
|
};
|
|
|
|
options.mergedEither = mkOption {
|
|
|
|
type = either (listOf types.str) (listOf types.str);
|
|
|
|
};
|
2025-02-19 16:49:58 +07:00
|
|
|
}
|
|
|
|
)
|
|
|
|
# Module B
|
|
|
|
(
|
|
|
|
{ ... }:
|
|
|
|
{
|
|
|
|
options.mergedAttrsWith = mkOption {
|
|
|
|
type = attrsOf (listOf types.str);
|
|
|
|
};
|
|
|
|
options.mergedListOf = mkOption {
|
|
|
|
type = listOf (listOf types.str);
|
|
|
|
};
|
2025-01-19 16:07:39 +01:00
|
|
|
options.mergedUnique = mkOption {
|
|
|
|
type = unique { message = ""; } (listOf types.str);
|
|
|
|
};
|
2025-01-19 16:21:33 +01:00
|
|
|
options.mergedNullOr = mkOption {
|
|
|
|
type = nullOr (listOf types.str);
|
|
|
|
};
|
2025-01-19 16:22:24 +01:00
|
|
|
options.mergedFunctionTo = mkOption {
|
|
|
|
type = functionTo (listOf types.str);
|
|
|
|
};
|
2025-01-19 16:39:44 +01:00
|
|
|
options.mergedEither = mkOption {
|
|
|
|
type = either (listOf types.str) (listOf types.str);
|
|
|
|
};
|
2025-02-19 16:49:58 +07:00
|
|
|
}
|
|
|
|
)
|
|
|
|
];
|
|
|
|
}
|