mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-10-31 22:51:22 +00:00
lib/modules.nix: Apply argument attr
of old byName
This commit is contained in:
parent
d1e18a369a
commit
c70a5e9223
@ -540,34 +540,26 @@ let
|
||||
mergeModules' = prefix: options: configs:
|
||||
let
|
||||
# an attrset 'name' => list of submodules that declare ‘name’.
|
||||
declsByName = (attr: f: modules:
|
||||
declsByName = (f: modules:
|
||||
zipAttrsWith (n: concatLists)
|
||||
(map (module: let subtree = module.${attr}; in
|
||||
(map (module: let subtree = module.options; in
|
||||
if !(builtins.isAttrs subtree) then
|
||||
throw (if attr == "config" then ''
|
||||
You're trying to define a value of type `${builtins.typeOf subtree}'
|
||||
rather than an attribute set for the option
|
||||
`${builtins.concatStringsSep "." prefix}'!
|
||||
|
||||
This usually happens if `${builtins.concatStringsSep "." prefix}' has option
|
||||
definitions inside that are not matched. Please check how to properly define
|
||||
this option by e.g. referring to `man 5 configuration.nix'!
|
||||
'' else ''
|
||||
throw ''
|
||||
An option declaration for `${builtins.concatStringsSep "." prefix}' has type
|
||||
`${builtins.typeOf subtree}' rather than an attribute set.
|
||||
Did you mean to define this outside of `options'?
|
||||
'')
|
||||
''
|
||||
else
|
||||
mapAttrs (n: f module) subtree
|
||||
) modules)) "options" (module: option:
|
||||
) modules)) (module: option:
|
||||
[{ inherit (module) _file; options = option; }]
|
||||
) options;
|
||||
# an attrset 'name' => list of submodules that define ‘name’.
|
||||
defnsByName = (attr: f: modules:
|
||||
defnsByName = (f: modules:
|
||||
zipAttrsWith (n: concatLists)
|
||||
(map (module: let subtree = module.${attr}; in
|
||||
(map (module: let subtree = module.config; in
|
||||
if !(builtins.isAttrs subtree) then
|
||||
throw (if attr == "config" then ''
|
||||
throw ''
|
||||
You're trying to define a value of type `${builtins.typeOf subtree}'
|
||||
rather than an attribute set for the option
|
||||
`${builtins.concatStringsSep "." prefix}'!
|
||||
@ -575,22 +567,18 @@ let
|
||||
This usually happens if `${builtins.concatStringsSep "." prefix}' has option
|
||||
definitions inside that are not matched. Please check how to properly define
|
||||
this option by e.g. referring to `man 5 configuration.nix'!
|
||||
'' else ''
|
||||
An option declaration for `${builtins.concatStringsSep "." prefix}' has type
|
||||
`${builtins.typeOf subtree}' rather than an attribute set.
|
||||
Did you mean to define this outside of `options'?
|
||||
'')
|
||||
''
|
||||
else
|
||||
mapAttrs (n: f module) subtree
|
||||
) modules)) "config" (module: value:
|
||||
) modules)) (module: value:
|
||||
map (config: { inherit (module) file; inherit config; }) (pushDownProperties value)
|
||||
) configs;
|
||||
# extract the definitions for each loc
|
||||
defnsByName' = (attr: f: modules:
|
||||
defnsByName' = (f: modules:
|
||||
zipAttrsWith (n: concatLists)
|
||||
(map (module: let subtree = module.${attr}; in
|
||||
(map (module: let subtree = module.config; in
|
||||
if !(builtins.isAttrs subtree) then
|
||||
throw (if attr == "config" then ''
|
||||
throw ''
|
||||
You're trying to define a value of type `${builtins.typeOf subtree}'
|
||||
rather than an attribute set for the option
|
||||
`${builtins.concatStringsSep "." prefix}'!
|
||||
@ -598,14 +586,10 @@ let
|
||||
This usually happens if `${builtins.concatStringsSep "." prefix}' has option
|
||||
definitions inside that are not matched. Please check how to properly define
|
||||
this option by e.g. referring to `man 5 configuration.nix'!
|
||||
'' else ''
|
||||
An option declaration for `${builtins.concatStringsSep "." prefix}' has type
|
||||
`${builtins.typeOf subtree}' rather than an attribute set.
|
||||
Did you mean to define this outside of `options'?
|
||||
'')
|
||||
''
|
||||
else
|
||||
mapAttrs (n: f module) subtree
|
||||
) modules)) "config" (module: value:
|
||||
) modules)) (module: value:
|
||||
[{ inherit (module) file; inherit value; }]
|
||||
) configs;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user