summary refs log tree commit diff
path: root/lib/modules.nix
diff options
context:
space:
mode:
authorRobert Hensing <robert@roberthensing.nl>2022-03-07 11:04:38 +0100
committerRobert Hensing <robert@roberthensing.nl>2022-03-07 11:07:50 +0100
commit02de37ca072841559df7063d66a25b91d82f9538 (patch)
treef24a5b48d5f5b7a93a30d20107ad0f98a2087862 /lib/modules.nix
parent17bf14a3e779074120d92c5b13132efdda95eeb0 (diff)
downloadnixpkgs-02de37ca072841559df7063d66a25b91d82f9538.tar
nixpkgs-02de37ca072841559df7063d66a25b91d82f9538.tar.gz
nixpkgs-02de37ca072841559df7063d66a25b91d82f9538.tar.bz2
nixpkgs-02de37ca072841559df7063d66a25b91d82f9538.tar.lz
nixpkgs-02de37ca072841559df7063d66a25b91d82f9538.tar.xz
nixpkgs-02de37ca072841559df7063d66a25b91d82f9538.tar.zst
nixpkgs-02de37ca072841559df7063d66a25b91d82f9538.zip
lib/modules.nix: Optimize optionSet legacy compat code
It's still in the hot path.
Diffstat (limited to 'lib/modules.nix')
-rw-r--r--lib/modules.nix10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/modules.nix b/lib/modules.nix
index 79d54e4a538..4c4d9f994da 100644
--- a/lib/modules.nix
+++ b/lib/modules.nix
@@ -761,13 +761,13 @@ rec {
       options = opt.options or
         (throw "Option `${showOption loc}' has type optionSet but has no option attribute, in ${showFiles opt.declarations}.");
       f = tp:
-        let optionSetIn = type: (tp.name == type) && (tp.functor.wrapped.name == "optionSet");
-        in
         if tp.name == "option set" || tp.name == "submodule" then
           throw "The option ${showOption loc} uses submodules without a wrapping type, in ${showFiles opt.declarations}."
-        else if optionSetIn "attrsOf" then types.attrsOf (types.submodule options)
-        else if optionSetIn "listOf"  then types.listOf  (types.submodule options)
-        else if optionSetIn "nullOr"  then types.nullOr  (types.submodule options)
+        else if (tp.functor.wrapped.name or null) == "optionSet" then
+          if tp.name == "attrsOf" then types.attrsOf (types.submodule options)
+          else if tp.name == "listOf" then types.listOf  (types.submodule options)
+          else if tp.name == "nullOr" then types.nullOr  (types.submodule options)
+          else tp
         else tp;
     in
       if opt.type.getSubModules or null == null