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
pythonPackagesExtensions: override all Python package sets at once #91850
Conversation
I would still prefer to go via an RFC but I don't see that happening any time soon really. |
699e9ad
to
6817787
Compare
On one hand, I'd rather not have yet another override mechanism but make an RFC about it instead. So eh, I'm about 50/50 on doing this. |
I marked this as stale due to inactivity. → More info |
Still important to me. Without something like this, it's impossible to share python package overlays with other people in a configuration-agnostic way. |
dd44da0
to
c4e9aef
Compare
Not just in mechanisms, but also in names! Overlays, extensions, overrides, ... I picked this up again because now with flakes being able to override several times becomes even more important. As mentioned before, ideally we go through a RFC (e.g. NixOS/rfcs#83) and unify things more, but I just don't find the time to work on that. |
Coming back to this, because I kind of need something like this at the moment! Because currently even if you try to overlay all packages via Seems like many other people agree too, I'm willing to merge if conflicts are fixed :) |
This comment was marked as duplicate.
This comment was marked as duplicate.
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/add-python-package-via-overlay/19783/2 |
c4e9aef
to
81252d0
Compare
I've rebased this commit. Also renamed overlays to extensions, to avoid confusion with Nixpkgs-wide overlays. |
81252d0
to
fa4ea08
Compare
Python package sets can be overridden by overriding an interpreter and passing in `packageOverrides = self: super: {...};`. This is fine in case you need a single interpreter, however, it does not help you when you want to override all sets. With this change it is possible to override all sets at once by appending a list of "extensions" to `pythonPackagesExtensions`. From reading the implementation you might wonder why a list is used, and not `lib.composeExtensions`? The reason is the latter requires knowledge of the library function. This approach should be easier for most users as it is similar to how we append to lists of e.g. inputs or patches when overriding a derivation.
fa4ea08
to
c9c200f
Compare
Lovely! ❤️ |
# Function that when called | ||
# - imports python-packages.nix | ||
# - adds spliced package sets to the package set | ||
# - applies overrides from `packageOverrides` and `pythonPackagesOverlays`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment uses the previous name, now pythonPackagesExtensions
@@ -133,6 +134,17 @@ let | |||
# test-overrideScope = let | |||
# myPackages = python.pkgs.overrideScope extension; | |||
# in assert myPackages.foobar == myPackages.numpy; myPackages.python.withPackages(ps: with ps; [ foobar ]); | |||
} // lib.optionalAttrs (python ? pythonAttr) { | |||
# Test applying overrides using pythonPackagesOverlays. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
Python package sets can be overridden by overriding an interpreter
and passing in
packageOverrides = self: super: {...};
. This is finein case you need a single interpreter, however, it does not help you
when you want to override all sets.
With this change it is possible to override all sets at once by
appending a list of "extensions" to
pythonPackagesExtensions
.From reading the implementation you might wonder why a list is used, and
not
lib.composeExtensions
? The reason is the latter requires knowledge ofthe library function. This approach should be easier for most users
as it is similar to how we append to lists of e.g. inputs or patches
when overriding a derivation.
Motivation for this change
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)