about summary refs log tree commit diff
path: root/lib
diff options
context:
space:
mode:
authorJan Tojnar <jtojnar@gmail.com>2020-01-11 08:54:42 +0100
committerJan Tojnar <jtojnar@gmail.com>2020-01-11 08:56:29 +0100
commitb0c2c96cbe12c5a3a280ffd2634ebe0c8507e8b0 (patch)
treeb0310deee3c18d12b2214dfc08671f9f54e0955e /lib
parente85b34c484d2c38cad3eaffbb97e211fecf852bf (diff)
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.
Diffstat (limited to 'lib')
-rw-r--r--lib/types.nix10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/types.nix b/lib/types.nix
index e86f6d3647611..cbbea00058d0e 100644
--- a/lib/types.nix
+++ b/lib/types.nix
@@ -340,18 +340,22 @@ rec {
             let
               padWidth = stringLength (toString (length def.value));
               unnamed = i: unnamedPrefix + fixedWidthNumber padWidth i;
+              nameAttrs = {
+                "environment.etc" = "target";
+              };
+              nameAttr = nameAttrs.${option} or "name";
               res =
                 { inherit (def) file;
                   value = listToAttrs (
                     imap1 (elemIdx: elem:
-                      { name  = elem.name or (unnamed elemIdx);
+                      { name  = elem.${nameAttr} or (unnamed elemIdx);
                         value = elem;
                       }) def.value);
                 };
               option = concatStringsSep "." loc;
               sample = take 3 def.value;
-              list = concatMapStrings (x: ''{ name = "${x.name or "unnamed"}"; ...} '') sample;
-              set = concatMapStrings (x: ''${x.name or "unnamed"} = {...}; '') sample;
+              list = concatMapStrings (x: ''{ ${nameAttr} = "${x.${nameAttr} or "unnamed"}"; ...} '') sample;
+              set = concatMapStrings (x: ''${x.${nameAttr} or "unnamed"} = {...}; '') sample;
               msg = ''
                 In file ${def.file}
                 a list is being assigned to the option config.${option}.