lib/types: improve loaOf warning
Not all modules use name attribute as the name of the submodule, for example, environment.etc uses target. We will need to maintain a list of exceptions.
This commit is contained in:
parent
e85b34c484
commit
b0c2c96cbe
@ -340,18 +340,22 @@ rec {
|
|||||||
let
|
let
|
||||||
padWidth = stringLength (toString (length def.value));
|
padWidth = stringLength (toString (length def.value));
|
||||||
unnamed = i: unnamedPrefix + fixedWidthNumber padWidth i;
|
unnamed = i: unnamedPrefix + fixedWidthNumber padWidth i;
|
||||||
|
nameAttrs = {
|
||||||
|
"environment.etc" = "target";
|
||||||
|
};
|
||||||
|
nameAttr = nameAttrs.${option} or "name";
|
||||||
res =
|
res =
|
||||||
{ inherit (def) file;
|
{ inherit (def) file;
|
||||||
value = listToAttrs (
|
value = listToAttrs (
|
||||||
imap1 (elemIdx: elem:
|
imap1 (elemIdx: elem:
|
||||||
{ name = elem.name or (unnamed elemIdx);
|
{ name = elem.${nameAttr} or (unnamed elemIdx);
|
||||||
value = elem;
|
value = elem;
|
||||||
}) def.value);
|
}) def.value);
|
||||||
};
|
};
|
||||||
option = concatStringsSep "." loc;
|
option = concatStringsSep "." loc;
|
||||||
sample = take 3 def.value;
|
sample = take 3 def.value;
|
||||||
list = concatMapStrings (x: ''{ name = "${x.name or "unnamed"}"; ...} '') sample;
|
list = concatMapStrings (x: ''{ ${nameAttr} = "${x.${nameAttr} or "unnamed"}"; ...} '') sample;
|
||||||
set = concatMapStrings (x: ''${x.name or "unnamed"} = {...}; '') sample;
|
set = concatMapStrings (x: ''${x.${nameAttr} or "unnamed"} = {...}; '') sample;
|
||||||
msg = ''
|
msg = ''
|
||||||
In file ${def.file}
|
In file ${def.file}
|
||||||
a list is being assigned to the option config.${option}.
|
a list is being assigned to the option config.${option}.
|
||||||
|
Loading…
Reference in New Issue
Block a user