mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-13 05:05:29 +03:00
Merge pull request #173621 from ncfavier/submodule-description
lib/types: allow custom `submoduleWith` descriptions
This commit is contained in:
commit
ec82f36ab6
1 changed files with 17 additions and 6 deletions
|
@ -570,6 +570,7 @@ rec {
|
||||||
{ modules
|
{ modules
|
||||||
, specialArgs ? {}
|
, specialArgs ? {}
|
||||||
, shorthandOnlyDefinesConfig ? false
|
, shorthandOnlyDefinesConfig ? false
|
||||||
|
, description ? null
|
||||||
|
|
||||||
# Internal variable to avoid `_key` collisions regardless
|
# Internal variable to avoid `_key` collisions regardless
|
||||||
# of `extendModules`. Wired through by `evalModules`.
|
# of `extendModules`. Wired through by `evalModules`.
|
||||||
|
@ -618,10 +619,14 @@ rec {
|
||||||
|
|
||||||
freeformType = base._module.freeformType;
|
freeformType = base._module.freeformType;
|
||||||
|
|
||||||
in
|
|
||||||
mkOptionType rec {
|
|
||||||
name = "submodule";
|
name = "submodule";
|
||||||
description = freeformType.description or name;
|
|
||||||
|
in
|
||||||
|
mkOptionType {
|
||||||
|
inherit name;
|
||||||
|
description =
|
||||||
|
if description != null then description
|
||||||
|
else freeformType.description or name;
|
||||||
check = x: isAttrs x || isFunction x || path.check x;
|
check = x: isAttrs x || isFunction x || path.check x;
|
||||||
merge = loc: defs:
|
merge = loc: defs:
|
||||||
(base.extendModules {
|
(base.extendModules {
|
||||||
|
@ -647,9 +652,7 @@ rec {
|
||||||
functor = defaultFunctor name // {
|
functor = defaultFunctor name // {
|
||||||
type = types.submoduleWith;
|
type = types.submoduleWith;
|
||||||
payload = {
|
payload = {
|
||||||
modules = modules;
|
inherit modules specialArgs shorthandOnlyDefinesConfig description;
|
||||||
specialArgs = specialArgs;
|
|
||||||
shorthandOnlyDefinesConfig = shorthandOnlyDefinesConfig;
|
|
||||||
};
|
};
|
||||||
binOp = lhs: rhs: {
|
binOp = lhs: rhs: {
|
||||||
modules = lhs.modules ++ rhs.modules;
|
modules = lhs.modules ++ rhs.modules;
|
||||||
|
@ -666,6 +669,14 @@ rec {
|
||||||
else if lhs.shorthandOnlyDefinesConfig == rhs.shorthandOnlyDefinesConfig
|
else if lhs.shorthandOnlyDefinesConfig == rhs.shorthandOnlyDefinesConfig
|
||||||
then lhs.shorthandOnlyDefinesConfig
|
then lhs.shorthandOnlyDefinesConfig
|
||||||
else throw "A submoduleWith option is declared multiple times with conflicting shorthandOnlyDefinesConfig values";
|
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";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue