Merge pull request #173621 from ncfavier/submodule-description

lib/types: allow custom `submoduleWith` descriptions

Changed files
+17 -6
lib
+17 -6
lib/types.nix
···
{ modules
, specialArgs ? {}
, shorthandOnlyDefinesConfig ? false
+
, description ? null
# Internal variable to avoid `_key` collisions regardless
# of `extendModules`. Wired through by `evalModules`.
···
freeformType = base._module.freeformType;
+
name = "submodule";
+
in
-
mkOptionType rec {
-
name = "submodule";
-
description = freeformType.description or name;
+
mkOptionType {
+
inherit name;
+
description =
+
if description != null then description
+
else freeformType.description or name;
check = x: isAttrs x || isFunction x || path.check x;
merge = loc: defs:
(base.extendModules {
···
functor = defaultFunctor name // {
type = types.submoduleWith;
payload = {
-
modules = modules;
-
specialArgs = specialArgs;
-
shorthandOnlyDefinesConfig = shorthandOnlyDefinesConfig;
+
inherit modules specialArgs shorthandOnlyDefinesConfig description;
};
binOp = lhs: rhs: {
modules = lhs.modules ++ rhs.modules;
···
else if lhs.shorthandOnlyDefinesConfig == rhs.shorthandOnlyDefinesConfig
then lhs.shorthandOnlyDefinesConfig
else throw "A submoduleWith option is declared multiple times with conflicting shorthandOnlyDefinesConfig values";
+
description =
+
if lhs.description == null
+
then rhs.description
+
else if rhs.description == null
+
then lhs.description
+
else if lhs.description == rhs.description
+
then lhs.description
+
else throw "A submoduleWith option is declared multiple times with conflicting descriptions";
};
};
};