-
-
Notifications
You must be signed in to change notification settings - Fork 14.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python's packageOverrides isn't composable #44426
Comments
Yep, this is a known issue, one which bothers me as well. I think we should pull the creation of the package set out of the interpreters. As a workaround, keep your |
Related #44196 |
Thanks for the suggestions and links. If I'm understanding where you are going with your comment, you are saying if the interpreter package pulled in the package set instead of producing it, you could then override the package set in the standard way with overlays. The interpreter would automatically pick up changes because it would be closed over the final package set. You could suck the final interpreter in the package set if you just re-exported it for compatibility without creating any loops. Cheers! -Tyson |
Exactly that! |
But, having the
(not tested) |
Thanks. I implemented that and it works well. 👍 Unless you would like to leave it open, feel free to close this issue. |
For a more standard-nixos version of said workaround, here's more or less what I'm using:
|
This should be solved with #54266
|
I'm not quite sure about this, but |
Actually this PR of mine solves this issue: #67422 It allows overrides of the form python3.pkgs.overrideScope' (self: super: {
# ...
}) Without discarding previous changes. And this with very little code changed. |
Due to NixOS#44426 the correct psutils package is not picked up, this commit changes the code so the correct version is always picked.
Due to #44426 the correct psutils package is not picked up, this commit changes the code so the correct version is always picked.
Thanks, with this i got it working. Though, it needed a few modifications to work. Here the corrected version in case anyone needs it:
self: super: {
pythonOverrides = selfPython: superPython: {
py = superPython.py.overridePythonAttrs (oldAttrs: {
pname = "foo";
});
};
}
self: super: rec {
pythonOverrides = self.lib.composeExtensions super.pythonOverrides (selfPython: superPython: {
pytest = superPython.pytest.overridePythonAttrs (oldAttrs: {
pname = "foobar";
});
});
python36 = super.python36.override { packageOverrides = pythonOverrides; };
} |
I forgot about this thread and I haven't read carefully enough to tell if this helps here, but maybe it's relevant; https://discourse.nixos.org/t/makeextensibleasoverlay/7116 |
I'm now using the following function for mach-nix to merge an arbitrary list of pythonOverrides: mergeOverrides = with pkgs.lib; overrides:
if length overrides == 0
then a: b: {} # return dummy overrides
else
if length overrides == 1
then elemAt overrides 0
else
let
last = head ( reverseList overrides );
rest = reverseList (tail ( reverseList overrides ));
in
composeExtensions (mergeOverrides rest) last; |
@DavHau |
Maybe we should put that in lib (or not) :p |
@deliciouslytyped that was proposed in #33258 |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/weird-overlay-behavior-with-python-packages/14469/7 |
To save others the substantial amount of trouble I had to deal with trying to get the various suggestions in this thread to work, if you're using mach-nix, the easiest way to deal with overrides is to avoid this entirely and instead use its built-in override methodology: |
I marked this as stale due to inactivity. → More info |
Not stale. |
I've just encoutered this issue when trying to override the broken As you can see here let
py = python3.override {
packageOverrides = self: super: {
awscrt = super.awscrt.overridePythonAttrs (oldAttrs: rec {
version = "0.13.11";
src = self.fetchPypi {
inherit (oldAttrs) pname;
inherit version;
sha256 = "sha256-Yx3I3RD57Nx6Cvm4moc5zmMbdsHeYiMghDfbQUor38E=";
};
});
};
}; It creates its own override of python3 meaning any of my attempts to mark Would the Right now I've worked around it by forking the derivation entirely and then overlaying that instead. It really sucks that this is outside of the usually pleasant overlay system. |
If you change the # awscli2.nix
let
pypkgs = python3.pkgs.overrideScope
(self: prev: {
awscrt = prev.awscrt.overridePythonAttrs (oldAttrs: rec {
version = "0.13.11";
src = self.fetchPypi {
inherit (oldAttrs) pname;
inherit version;
sha256 = "sha256-Yx3I3RD57Nx6Cvm4moc5zmMbdsHeYiMghDfbQUor38E=";
};
});
});
in # overlay.nix
self: prev: {
python3 = prev.python3 // {
pkgs = prev.python3.pkgs.overrideScope (self: prev: {
pyopenssl = prev.pyopenssl.overrideAttrs (_: { meta.broken = false; });
twisted = prev.twisted.overridePythonAttrs (_: { doCheck = false; });
});
};
} I don't currently see any examples in |
This seems like a definite usability hurdle. Three different overrides required to set one parameter on two Python packages. |
👍 on the I have two functions that each return sets of python packages.
The result is an overlay, exported as part of a flake. The {
overlays.python = final: prev:
let
pythonPkgsScope = prev.python3.pkgs.overrideScope (prev.lib.composeManyExtensions [
(_: _: newPackages final prev)
]);
in
{
python3 = prev.python3 // {
pkgs = pythonPkgsScope;
packageOverrides = lib.warn ''
`python3.packageOverrides` does not compose;
instead, manually replace the `pkgs` attr of `python3` with `python3.pkgs.overrideScope` applied to the overrides.
''
prev.python3.packageOverrides;
};
python3Packages = pythonPkgsScope;
};
} This overlay also works if applied after one which uses [Edit: turns out setting |
As discussed at NixOS/nixpkgs#44426, `packageOverrides` is not composable. Haskell packaging has (had?) a similar problem. The solution, which works fairly elegantly, is to instead use `python3.pkgs.overrideScope` to define a new set of `pkgs`, and replace the original `python3.pkgs` with that. Importantly, the arguments to `packageOverrides` do not need to change, to be used with `overrideScope`. Note, also, that `python3.pkgs.overrideScope` corresponds to `lib.overrideScope'` (with the prime).
The nixos module system could probably be used to solve this problem nicely. |
see #44426 ("Python's packageOverrides isn't composable") for why this is a useful thing to do.
This doesn't seem to work for me. I have the following overlay applied to nixpkgs final: prev: {
python3 = prev.python3 // {
pkgs = prev.python3.pkgs.overrideScope (python-final: python-prev: {
solidpython2 = python-final.callPackage ./solidpython2.nix { };
});
};
} where { buildPythonPackage, fetchPypi }:
buildPythonPackage rec {
............
} and then I have this {
environment.systemPackages = with pkgs; [
blah
blah
(python3.withPackages (ps: with ps; [
blah
blah
solidpython2
]))
];
} which ends in |
@WizardUli It looks like nixpkgs/pkgs/development/interpreters/python/default.nix Lines 100 to 101 in 2ad9cc7
(although I don't understand how I've had success with this kind of usage:
|
That's exactly what I've ended up using. |
You can just use the |
By the way, there is now |
Issue description
@FRidh the
packageOverrides
function argument approach to overriding package used in the base python function (here is the 2.7 one) doesn't compose in overlays. Specifically, if you follow the directions in the nixpkgs manual only the last declared override winds up being applied.I haven't actually thought of a solution to this yet, other than determining that it is pretty much impossible to work around as you can only get a hold of a closed version of the previous package set via
python.pkgs
. Perhaps looking into the haskell infrastructure might give some directions (haven't looked at it in a while, but the fixpoint stuff looks like it came from there)?Steps to reproduce
Put the following into
~/.config/nixpkgs/overlays/1.nix
and this into
~/.config/nixpkgs/overlays/2.nix
Ideally both of these would get applied. This is not the case though as you can see from the following
If you move the
2.nix
file aside then you see the override from1.nix
but not2.nix
The text was updated successfully, but these errors were encountered: