···
···
49
+
inherit (lib.strings)
50
+
isConvertibleWithToString
showDeclPrefix = loc: decl: prefix:
···
modules = collectedImports.modules;
406
-
disabled = module.disabledModules ++ collectedImports.disabled;
410
+
disabled = (if module.disabledModules != [] then [{ file = module._file; disabled = module.disabledModules; }] else []) ++ collectedImports.disabled;
# filterModules :: String -> { disabled, modules } -> [ Module ]
···
# modules recursively. It returns the final list of unique-by-key modules
filterModules = modulesPath: { disabled, modules }:
415
-
moduleKey = m: if isString m && (builtins.substring 0 1 m != "/")
416
-
then toString modulesPath + "/" + m
418
-
disabledKeys = map moduleKey disabled;
419
+
moduleKey = file: m:
422
+
if builtins.substring 0 1 m == "/"
424
+
else toString modulesPath + "/" + m
426
+
else if isConvertibleWithToString m
428
+
if m?key && m.key != toString m
430
+
throw "Module `${file}` contains a disabledModules item that is an attribute set that can be converted to a string (${toString m}) but also has a `.key` attribute (${m.key}) with a different value. This makes it ambiguous which module should be disabled."
439
+
then throw "Module `${file}` contains a disabledModules item that is an attribute set, presumably a module, that does not have a `key` attribute. This means that the module system doesn't have any means to identify the module that should be disabled. Make sure that you've put the correct value in disabledModules: a string path relative to modulesPath, a path value, or an attribute set with a `key` attribute."
440
+
else throw "Each disabledModules item must be a path, string, or a attribute set with a key attribute, or a value supported by toString. However, one of the disabledModules items in `${toString file}` is none of that, but is of type ${builtins.typeOf m}.";
442
+
disabledKeys = concatMap ({ file, disabled }: map (moduleKey file) disabled) disabled;
keyFilter = filter (attrs: ! elem attrs.key disabledKeys);
in map (attrs: attrs.module) (builtins.genericClosure {
startSet = keyFilter modules;