about summary refs log tree commit diff
path: root/lib/modules.nix
diff options
context:
space:
mode:
authorRobert Hensing <robert@roberthensing.nl>2023-07-11 11:43:16 +0200
committerRobert Hensing <robert@roberthensing.nl>2023-07-11 12:22:08 +0200
commitc70a5e922322f081c6cfb249a6cf4fbf291e53ee (patch)
tree7d7eccf5662183411743d9384b039e8dd7aa754d /lib/modules.nix
parentd1e18a369a6c89d150a503c599d11674fa18a581 (diff)
downloadnixlib-c70a5e922322f081c6cfb249a6cf4fbf291e53ee.tar
nixlib-c70a5e922322f081c6cfb249a6cf4fbf291e53ee.tar.gz
nixlib-c70a5e922322f081c6cfb249a6cf4fbf291e53ee.tar.bz2
nixlib-c70a5e922322f081c6cfb249a6cf4fbf291e53ee.tar.lz
nixlib-c70a5e922322f081c6cfb249a6cf4fbf291e53ee.tar.xz
nixlib-c70a5e922322f081c6cfb249a6cf4fbf291e53ee.tar.zst
nixlib-c70a5e922322f081c6cfb249a6cf4fbf291e53ee.zip
lib/modules.nix: Apply argument `attr` of old byName
Diffstat (limited to 'lib/modules.nix')
-rw-r--r--lib/modules.nix46
1 files changed, 15 insertions, 31 deletions
diff --git a/lib/modules.nix b/lib/modules.nix
index 730d30576f1d..84715a5b1bb8 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;