python3.pkgs: fix splice through unsupported hosts
Previously, unless unsupported platforms were allowed, the following would fail to evaluate (from an "x86_64-linux" system): pkgsCross.x86_64-freebsd.__splicedPackages.docutils.__spliced.buildHost It shouldn't have, because the buildHost package ends up being for Linux. This broke evaluation of e.g. pkgsCross.x86_64-freebsd.libdrm, because it has docutils in nativeBuildInputs. mkDerivation would try to go through __spliced.buildHost on docutils to get to the Linux version, but the check in ensurePythonModules would kick in first, triggering the meta check because of the equality check in the implementation of hasPythonModule, which would fail because Python is not marked as supported on FreeBSD in Nixpkgs at the moment. Thus, even though they're not supposed to be, the meta checks would be triggered even though the only attribute being accessed on the unsupported derivation was __spliced. We can fix this by using the same mechanism used to implement the meta checks themselves: lib.extendDerivation. Now, attempting to access drvPath or outPath on an attribute that fails the validity check will produce the same error as before, but other accesses will be allowed through, fixing splicing. I've tested evaluation of packages that pass and fail the validity check, and confirmed that the behaviour is still correct.
This commit is contained in:
parent
02ee33a5c1
commit
b682fef8e9
@ -36,8 +36,12 @@
|
||||
stdenv
|
||||
];
|
||||
providesSetupHook = lib.attrByPath [ "provides" "setupHook"] false;
|
||||
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.";
|
||||
valid = value: pythonPackages.hasPythonModule value || providesSetupHook value || lib.elem value exceptions;
|
||||
func = name: value:
|
||||
if lib.isDerivation value then
|
||||
lib.extendDerivation (valid value || throw "${name} should use `buildPythonPackage` or `toPythonModule` if it is to be part of the Python packages set.") {} value
|
||||
else
|
||||
value;
|
||||
in lib.mapAttrs func items;
|
||||
in ensurePythonModules (callPackage
|
||||
# Function that when called
|
||||
|
Loading…
Reference in New Issue
Block a user