git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #163127 from hercules-ci/optimize-optionSet-compat

lib/modules.nix: Optimize optionSet legacy compat code

commit679ec68d574427606697be14bfc6a69db7bc28b9 authorRobert Hensing <roberth@users.noreply.github.com> dateFri 11 Mar 2022, 17:36 (5 years ago) parentf5331b402de37c
1 file changed+5−5
lib/modules.nix+5−5
lib/modules.nix+5−5
@@ -761,13 +761,13 @@ rec {
761761 options = opt.options or
762762 (throw "Option `${showOption loc}' has type optionSet but has no option attribute, in ${showFiles opt.declarations}.");
763763 f = tp:
764− let optionSetIn = type: (tp.name == type) && (tp.functor.wrapped.name == "optionSet");
765− in
766764 if tp.name == "option set" || tp.name == "submodule" then
767765 throw "The option ${showOption loc} uses submodules without a wrapping type, in ${showFiles opt.declarations}."
768− else if optionSetIn "attrsOf" then types.attrsOf (types.submodule options)
769− else if optionSetIn "listOf" then types.listOf (types.submodule options)
770− else if optionSetIn "nullOr" then types.nullOr (types.submodule options)
766+ else if (tp.functor.wrapped.name or null) == "optionSet" then
767+ if tp.name == "attrsOf" then types.attrsOf (types.submodule options)
768+ else if tp.name == "listOf" then types.listOf (types.submodule options)
769+ else if tp.name == "nullOr" then types.nullOr (types.submodule options)
770+ else tp
771771 else tp;
772772 in
773773 if opt.type.getSubModules or null == null