mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-07-06 17:13:24 -05:00
parent
949c0636d7
commit
495906d50a
2 changed files with 36 additions and 2 deletions
|
|
@ -120,7 +120,17 @@ in
|
||||||
assert config.merged.positive == { yay = 100; };
|
assert config.merged.positive == { yay = 100; };
|
||||||
assert config.merged.extensi-foo == { extensible = "foo"; };
|
assert config.merged.extensi-foo == { extensible = "foo"; };
|
||||||
assert config.merged.extensi-bar == { extensible = "bar"; };
|
assert config.merged.extensi-bar == { extensible = "bar"; };
|
||||||
|
assert config.docs."submodules.<name>.foo.bar".declarations == [ __curPos.file ];
|
||||||
assert config.docs."submodules.<name>.foo.bar".type == "signed integer";
|
assert config.docs."submodules.<name>.foo.bar".type == "signed integer";
|
||||||
|
assert
|
||||||
|
lib.length
|
||||||
|
(options.submodules.type.nestedTypes.elemType.nestedTypes.foo.type.getSubOptions [ ])
|
||||||
|
.bar.declarationPositions == 1;
|
||||||
|
assert
|
||||||
|
(lib.head
|
||||||
|
(options.submodules.type.nestedTypes.elemType.nestedTypes.foo.type.getSubOptions [ ])
|
||||||
|
.bar.declarationPositions
|
||||||
|
).file == __curPos.file;
|
||||||
assert config.docs."submodules.<name>.qux".type == "string";
|
assert config.docs."submodules.<name>.qux".type == "string";
|
||||||
assert config.docs."submodules.<name>.qux".declarations == [ __curPos.file ];
|
assert config.docs."submodules.<name>.qux".declarations == [ __curPos.file ];
|
||||||
assert
|
assert
|
||||||
|
|
@ -133,8 +143,11 @@ in
|
||||||
assert config.docs."submodules.<name>.qux".description == "A qux for when you don't want a foo";
|
assert config.docs."submodules.<name>.qux".description == "A qux for when you don't want a foo";
|
||||||
assert config.docs."submodules.<name>.qux".readOnly == false;
|
assert config.docs."submodules.<name>.qux".readOnly == false;
|
||||||
assert config.docs."submodules.<name>.qux".visible == true;
|
assert config.docs."submodules.<name>.qux".visible == true;
|
||||||
# Not available (yet?)
|
assert
|
||||||
# assert config.docs."submodules.<name>.qux".declarationsWithPositions == [ ... ];
|
lib.length options.submodules.type.nestedTypes.elemType.nestedTypes.qux.declarationPositions == 1;
|
||||||
|
assert
|
||||||
|
(lib.head options.submodules.type.nestedTypes.elemType.nestedTypes.qux.declarationPositions).file
|
||||||
|
== __curPos.file;
|
||||||
assert options.submodules.declarations == [ __curPos.file ];
|
assert options.submodules.declarations == [ __curPos.file ];
|
||||||
assert lib.length options.submodules.declarationPositions == 1;
|
assert lib.length options.submodules.declarationPositions == 1;
|
||||||
assert (lib.head options.submodules.declarationPositions).file == __curPos.file;
|
assert (lib.head options.submodules.declarationPositions).file == __curPos.file;
|
||||||
|
|
|
||||||
|
|
@ -1140,6 +1140,27 @@ rec {
|
||||||
else
|
else
|
||||||
throw "The option `${showOption loc}` is defined as ${lib.strings.escapeNixIdentifier choice}, but ${lib.strings.escapeNixIdentifier choice} is not among the valid choices (${choicesStr}). Value ${choice} was defined in ${showFiles (getFiles defs)}.";
|
throw "The option `${showOption loc}` is defined as ${lib.strings.escapeNixIdentifier choice}, but ${lib.strings.escapeNixIdentifier choice} is not among the valid choices (${choicesStr}). Value ${choice} was defined in ${showFiles (getFiles defs)}.";
|
||||||
nestedTypes = tags;
|
nestedTypes = tags;
|
||||||
|
getSubModules =
|
||||||
|
let
|
||||||
|
tagsWithSubModules = filterAttrs (_: mods: mods != null) (
|
||||||
|
mapAttrs (_: opt: opt.type.getSubModules) tags
|
||||||
|
);
|
||||||
|
in
|
||||||
|
if tagsWithSubModules == { } then null else [ tagsWithSubModules ];
|
||||||
|
substSubModules =
|
||||||
|
allWrappedModules:
|
||||||
|
let
|
||||||
|
tagsWithNewTypes = zipAttrsWith (tag: tags.${tag}.type.substSubModules) (
|
||||||
|
concatMap (
|
||||||
|
{ _file, imports }: map (mapAttrs (_: imports: { inherit _file imports; })) imports
|
||||||
|
) allWrappedModules
|
||||||
|
);
|
||||||
|
in
|
||||||
|
attrTag (
|
||||||
|
mapAttrs (
|
||||||
|
tag: opt: opt // (optionalAttrs (tagsWithNewTypes ? ${tag}) { type = tagsWithNewTypes.${tag}; })
|
||||||
|
) tags
|
||||||
|
);
|
||||||
functor = defaultFunctor "attrTag" // {
|
functor = defaultFunctor "attrTag" // {
|
||||||
type = { tags, ... }: lib.types.attrTag tags;
|
type = { tags, ... }: lib.types.attrTag tags;
|
||||||
payload = { inherit tags; };
|
payload = { inherit tags; };
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue