-
-
Notifications
You must be signed in to change notification settings - Fork 15k
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
Package duplicate dependencies and overriding nixpkgs pkgs #44255
Comments
This PR seems related: #44196 |
What does the dependency tree look like?
Right, that's quite common and why we put this check in here, just to make sure you don't accidentally end up with multiple versions in a closure. Python doesn't support multiple versions of a package, so one should indeed override the value for the whole package set.
Almost. This is documented in the Nixpkgs manual, so I am not going to repeat it here.
Yes, it is. Maybe it will get better with #44196. |
@FRidh thanks for the response. I did find that PR. Just regarding you saying there is an almost better way to do it, are you referring to: {
pkgs ? import ./pkgs.nix
}:
let
pkgs_ = pkgs // {
config = pkgs.config // {
packageOverrides = pkgs: {
python36 = pkgs.python36.override {
packageOverrides = self: super: {
matplotlib = super.matplotlib.override { enableQt = true; };
};
};
};
};
};
in
with pkgs_; Because I find that my |
Oh that method doesn't actually work. I can't find a way to override the package set, when I already have the package set. |
Here's what I would want ideally. A { pkgs ? import ./pkgs.nix }:
let
pkgs_ = pkgs.override { ... };
in
# do stuff with pkgs_ including passing the pkgs_ into subderivations
# import ./someotherderivation.nix { pkgs = pkgs_; } Where the import (fetchTarball https://github.com/NixOS/nixpkgs-channels/archive/650d8c93a16333e9390db0269327bd2d47f02fc7.tar.gz) {} But since I cannot find a way to override while having pkgs, the only working example I can get is something that is passed as a parameter to the nixpkgs function: { pkgs ? import ./nixpkgs.nix { config = import ./overrides.nix; } }:
# do stuff with pkgs Where the import (fetchTarball https://github.com/NixOS/nixpkgs-channels/archive/650d8c93a16333e9390db0269327bd2d47f02fc7.tar.gz) The problem with the above is that downstream derivations cannot pass their own pkgs without losing this specific derivation's overrides. Essentially the overrides becomes non-composable. |
I found that you can use |
I found that when attempting to build a complex Python application where itself and its dependencies uses matplotlib, it is possible to get this problem:
The main reason is when you use:
In your
propagatedBuildInputs
.The problem is that your dependencies may rely on the default
pkgs.matplotlib
, whereas your top level package may actually expect to use theqt
backend.I found that the solution to this was to create an override at the
nixpkgs
level:From there, every subsequent expression will reuse the same
pkgs
, and all packages will be using the overridden matplotlib.My question here is, is this way that's expected to work? Is there no better way to do this? It seems overly verbose to achieve this. Furthermore, this requires you to have the
nixpkgs
function, instead of thepkgs
attribute. I could not find a way to override thepkgs
attribute instead of passing it as a theconfig
attribute to thenixpkgs
function.The text was updated successfully, but these errors were encountered: