Recently I’ve encountered a problem with my personal overlay containing custom versions of Python packages from nixpkgs. When using two overlays for a package (replacing the existing package with my version; overriding some options of that package), it seems like the package entry “resets” to the nixpkgs version. Curiosly, this does not happen if a package is in pkgs root.
nix-repl> o_n = import ./overlays_numpy.nix
nix-repl> pkgs = import <nixpkgs> { overlays = [ o_n.overlay1 o_n.overlay2 ]; }
nix-repl> pkgs.python3Packages.numpy.optionA
error: anonymous function at /nix/store/ifg0cf324ylhvicadnh3pq0rzn8p8n9w-nixos-21.05.2132.733682c3292/nixos/pkgs/development/python-modules/numpy/default.nix:1:1 called with unexpected argument 'optionA', at /nix/store/ifg0cf324ylhvicadnh3pq0rzn8p8n9w-nixos-21.05.2132.733682c3292/nixos/lib/customisation.nix:69:16
In this thread it is mentioned that python.override breaks if it is used in more than one overlay. Is it true? If it is, how to work around this situation?
After some more experimentation it seems to me that when overriding python package set the original Python package set is always used as “super”. E.g., newly added packages via python.override disappear even if python = python.override { self = python; packageOverrides self: super: {}; };. Here is an example:
While calling nix-build --no-out-link multi_python_overrides.nix it returns not this:
trace: true
error: derivation name missing
but this
error: attribute 'my-test' missing, at multi_python_overrides.nix:23:17
If package override function returns an empty attrset, the error is about missing my-part attribute in python3_2.pkgs. Trying to modify only the package set as per manual (myPythonPackages = pkgs.pythonPackages.override { overrides = self: super: {...}; };), the same problem arises.
I’ve searched the Nixpkgs docs and haven’t found any clue about what I’m missing. I haven’t seen any examples of multiple overrides though.
Essentially in the current state of things, Python overrides do not compose. I don’t have my browser history at hand, but if you search for issues and PRs on GitHub you will find multiple unfinished attempts to rework this.
Thanks a lot for the info. Well, it’s quite unfortunate, and I don’t feel knowledgeable enough of Nix/Nixpkgs to do a proper rework myself. I’ll just try to hack a solution that would at least work in my specific case.