From c70a5e922322f081c6cfb249a6cf4fbf291e53ee Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Tue, 11 Jul 2023 11:43:16 +0200 Subject: lib/modules.nix: Apply argument `attr` of old byName --- lib/modules.nix | 46 +++++++++++++++------------------------------- 1 file changed, 15 insertions(+), 31 deletions(-) (limited to 'lib/modules.nix') diff --git a/lib/modules.nix b/lib/modules.nix index 730d30576f1d0..84715a5b1bb88 100644 --- a/lib/modules.nix +++ b/lib/modules.nix @@ -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; -- cgit 1.4.1