lib/modules: Memoize remaining lookups into builtins
Similar to the previous commit about lookups into lib Main benefits - consistent - faster - shorter
This commit is contained in:
parent
fed26baf1e
commit
4eb6883b86
@ -16,6 +16,7 @@ let
|
|||||||
foldl'
|
foldl'
|
||||||
functionArgs
|
functionArgs
|
||||||
getAttrFromPath
|
getAttrFromPath
|
||||||
|
genericClosure
|
||||||
head
|
head
|
||||||
id
|
id
|
||||||
imap1
|
imap1
|
||||||
@ -35,9 +36,14 @@ let
|
|||||||
optionalString
|
optionalString
|
||||||
recursiveUpdate
|
recursiveUpdate
|
||||||
reverseList sort
|
reverseList sort
|
||||||
|
seq
|
||||||
setAttrByPath
|
setAttrByPath
|
||||||
|
substring
|
||||||
throwIfNot
|
throwIfNot
|
||||||
|
trace
|
||||||
|
typeOf
|
||||||
types
|
types
|
||||||
|
unsafeGetAttrPos
|
||||||
warn
|
warn
|
||||||
warnIf
|
warnIf
|
||||||
zipAttrs
|
zipAttrs
|
||||||
@ -304,7 +310,7 @@ let
|
|||||||
else throw baseMsg
|
else throw baseMsg
|
||||||
else null;
|
else null;
|
||||||
|
|
||||||
checked = builtins.seq checkUnmatched;
|
checked = seq checkUnmatched;
|
||||||
|
|
||||||
extendModules = extendArgs@{
|
extendModules = extendArgs@{
|
||||||
modules ? [],
|
modules ? [],
|
||||||
@ -421,7 +427,7 @@ let
|
|||||||
moduleKey = file: m:
|
moduleKey = file: m:
|
||||||
if isString m
|
if isString m
|
||||||
then
|
then
|
||||||
if builtins.substring 0 1 m == "/"
|
if substring 0 1 m == "/"
|
||||||
then m
|
then m
|
||||||
else toString modulesPath + "/" + m
|
else toString modulesPath + "/" + m
|
||||||
|
|
||||||
@ -439,11 +445,11 @@ let
|
|||||||
|
|
||||||
else if isAttrs m
|
else if isAttrs m
|
||||||
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."
|
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."
|
||||||
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}.";
|
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 ${typeOf m}.";
|
||||||
|
|
||||||
disabledKeys = concatMap ({ file, disabled }: map (moduleKey file) disabled) disabled;
|
disabledKeys = concatMap ({ file, disabled }: map (moduleKey file) disabled) disabled;
|
||||||
keyFilter = filter (attrs: ! elem attrs.key disabledKeys);
|
keyFilter = filter (attrs: ! elem attrs.key disabledKeys);
|
||||||
in map (attrs: attrs.module) (builtins.genericClosure {
|
in map (attrs: attrs.module) (genericClosure {
|
||||||
startSet = keyFilter modules;
|
startSet = keyFilter modules;
|
||||||
operator = attrs: keyFilter attrs.modules;
|
operator = attrs: keyFilter attrs.modules;
|
||||||
});
|
});
|
||||||
@ -555,14 +561,14 @@ let
|
|||||||
(module: let subtree = module.options; in
|
(module: let subtree = module.options; in
|
||||||
if !(isAttrs subtree) then
|
if !(isAttrs subtree) then
|
||||||
throw ''
|
throw ''
|
||||||
An option declaration for `${builtins.concatStringsSep "." prefix}' has type
|
An option declaration for `${concatStringsSep "." prefix}' has type
|
||||||
`${builtins.typeOf subtree}' rather than an attribute set.
|
`${typeOf subtree}' rather than an attribute set.
|
||||||
Did you mean to define this outside of `options'?
|
Did you mean to define this outside of `options'?
|
||||||
''
|
''
|
||||||
else
|
else
|
||||||
mapAttrs
|
mapAttrs
|
||||||
(n: option:
|
(n: option:
|
||||||
[{ inherit (module) _file; pos = builtins.unsafeGetAttrPos n subtree; options = option; }]
|
[{ inherit (module) _file; pos = unsafeGetAttrPos n subtree; options = option; }]
|
||||||
)
|
)
|
||||||
subtree
|
subtree
|
||||||
)
|
)
|
||||||
@ -577,11 +583,11 @@ let
|
|||||||
# The implementation of this check used to be tied to a superficially similar check for
|
# The implementation of this check used to be tied to a superficially similar check for
|
||||||
# options, so maybe that's why this is here.
|
# options, so maybe that's why this is here.
|
||||||
isAttrs c.config || throw ''
|
isAttrs c.config || throw ''
|
||||||
In module `${c.file}', you're trying to define a value of type `${builtins.typeOf c.config}'
|
In module `${c.file}', you're trying to define a value of type `${typeOf c.config}'
|
||||||
rather than an attribute set for the option
|
rather than an attribute set for the option
|
||||||
`${builtins.concatStringsSep "." prefix}'!
|
`${concatStringsSep "." prefix}'!
|
||||||
|
|
||||||
This usually happens if `${builtins.concatStringsSep "." prefix}' has option
|
This usually happens if `${concatStringsSep "." prefix}' has option
|
||||||
definitions inside that are not matched. Please check how to properly define
|
definitions inside that are not matched. Please check how to properly define
|
||||||
this option by e.g. referring to `man 5 configuration.nix'!
|
this option by e.g. referring to `man 5 configuration.nix'!
|
||||||
''
|
''
|
||||||
@ -1127,7 +1133,7 @@ let
|
|||||||
inherit from to;
|
inherit from to;
|
||||||
visible = false;
|
visible = false;
|
||||||
warn = true;
|
warn = true;
|
||||||
use = builtins.trace "Obsolete option `${showOption from}' is used. It was renamed to `${showOption to}'.";
|
use = trace "Obsolete option `${showOption from}' is used. It was renamed to `${showOption to}'.";
|
||||||
};
|
};
|
||||||
|
|
||||||
mkRenamedOptionModuleWith = {
|
mkRenamedOptionModuleWith = {
|
||||||
|
Loading…
Reference in New Issue
Block a user