python3.pkgs: fix splice through unsupported hosts #212832
python3.pkgs: fix splice through unsupported hosts #212832alyssais merged 2 commits intoNixOS:masterfrom
Conversation
7fa9326 to
d3e9e24
Compare
d3e9e24 to
09aabe2
Compare
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.
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.
09aabe2 to
47ac733
Compare
nixpkgs/pkgs/development/interpreters/python/default.nix Lines 34 to 41 in de836e3
I would love to know why that equality check is there. Also, testing meta-check-failing derivations for equality against each other shouldn't
Yeah they should only be triggered upon access to |
To avoid mixing Python packages of different interpreter versions. Applications don't provide a module and so we stop recursing. We also stop recursing when we encounter a Python module but it is not for the same interpreter. The idea here is that, when we would use this with |
Interesting trick. Could this also fix overriding a package that has |
Yes, I think it could! |
Description of changes
Previously, unless unsupported platforms were allowed, the following would fail to evaluate (from an "x86_64-linux" system):
It shouldn't have, because the
buildHostpackage ends up being for Linux. This broke evaluation of e.g.pkgsCross.x86_64-freebsd.libdrm, because it hasdocutilsinnativeBuildInputs.mkDerivationwould try to go through__spliced.buildHoston docutils to get to the Linux version, but the check inensurePythonModuleswould kick in first, triggering the meta check because of the equality check in the implementation ofhasPythonModule, 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 accessdrvPathoroutPathon 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.
While I was here, I also simplified the logic in the validity check.
Things done
sandbox = trueset innix.conf? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)nixos/doc/manual/md-to-db.shto update generated release notes