diff options
author | Robert Hensing <robert@roberthensing.nl> | 2023-07-11 11:43:16 +0200 |
---|---|---|
committer | Robert Hensing <robert@roberthensing.nl> | 2023-07-11 12:22:08 +0200 |
commit | c70a5e922322f081c6cfb249a6cf4fbf291e53ee (patch) | |
tree | 7d7eccf5662183411743d9384b039e8dd7aa754d /lib/modules.nix | |
parent | d1e18a369a6c89d150a503c599d11674fa18a581 (diff) | |
download | nixpkgs-c70a5e922322f081c6cfb249a6cf4fbf291e53ee.tar nixpkgs-c70a5e922322f081c6cfb249a6cf4fbf291e53ee.tar.gz nixpkgs-c70a5e922322f081c6cfb249a6cf4fbf291e53ee.tar.bz2 nixpkgs-c70a5e922322f081c6cfb249a6cf4fbf291e53ee.tar.lz nixpkgs-c70a5e922322f081c6cfb249a6cf4fbf291e53ee.tar.xz nixpkgs-c70a5e922322f081c6cfb249a6cf4fbf291e53ee.tar.zst nixpkgs-c70a5e922322f081c6cfb249a6cf4fbf291e53ee.zip |
lib/modules.nix: Apply argument `attr` of old byName
Diffstat (limited to 'lib/modules.nix')
-rw-r--r-- | lib/modules.nix | 46 |
1 files changed, 15 insertions, 31 deletions
diff --git a/lib/modules.nix b/lib/modules.nix index 730d30576f1..84715a5b1bb 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; |