python3.pkgs: simplify ensurePythonModules logic

It wasn't clear before, but it turns out that this is just four
separate conditions, and an attribute is valid if any of the
conditions is true, so we don't need a sea of parentheses to express
it.
This commit is contained in:
Alyssa Ross 2023-01-26 20:10:29 +00:00
parent f69c8b761a
commit 02ee33a5c1

View file

@ -36,7 +36,7 @@
stdenv
];
providesSetupHook = lib.attrByPath [ "provides" "setupHook"] false;
valid = value: !((lib.isDerivation value) && !((pythonPackages.hasPythonModule value) || (providesSetupHook value))) || (lib.elem value exceptions);
valid = value: !lib.isDerivation value || pythonPackages.hasPythonModule value || providesSetupHook value || lib.elem value exceptions;
func = name: value: if (valid value) then value else throw "${name} should use `buildPythonPackage` or `toPythonModule` if it is to be part of the Python packages set.";
in lib.mapAttrs func items;
in ensurePythonModules (callPackage