Skip to content
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: withPackages and overrides does not result in correct `passthru` #64334

Closed
adisbladis opened this issue Jul 5, 2019 · 4 comments

Comments

Projects
None yet
2 participants
@adisbladis
Copy link
Member

commented Jul 5, 2019

Issue description

Using withPackages together with overrides currently does not work as expected.
Overrides does not propagate to withPackages.

Steps to reproduce

We can demonstrate this easily in the repl:

This works exactly as expected

nix-repl> (python3.override { packageOverrides=(self: super: { requests="hello"; }); }).passthru.pkgs.requests  
"hello"

This does not:

nix-repl> ((python3.override { packageOverrides=(self: super: { requests="hello"; }); }).withPackages(ps: [ps.requests])).passthru.pkgs.requests
«derivation /nix/store/qfnz62wvq8xbmf6zldxqfa205rklhwmv-python3.7-requests-2.21.0.drv»

I would expect the second case to also evaluate to my overriden package.

Technical details

Please run nix-shell -p nix-info --run "nix-info -m" and paste the
results.

cc @FRidh

@FRidh

This comment has been minimized.

Copy link
Member

commented Jul 5, 2019

See "9.14.2.2.1.2. Overriding Python packages" in the Nixpkgs manual, rewritten as

with import <nixpkgs> {};

(let
  python = let
    packageOverrides = self: super: {
      foo = super.numpy.overridePythonAttrs(old: rec {
        name = "foo";
      });
    };
  in pkgs.python3.override {inherit packageOverrides;};

in python.withPackages(ps: [ps.foo])).env

The composition does function, however, the passthru seems to be incorrect. Just replace .env with .passthru.pkgs.foo .

@FRidh FRidh changed the title Python: withPackages and overrides does not compose Python: withPackages and overrides does not result in correct `passthru` Jul 5, 2019

@FRidh

This comment has been minimized.

Copy link
Member

commented Jul 5, 2019

Using the following solves the issue:

with import <nixpkgs> {};

(let
  python = let
    packageOverrides = self: super: {
      foo = super.numpy.overridePythonAttrs(old: rec {
        name = "foo";
      });
    };
  in pkgs.python3.override {inherit packageOverrides; self = python;};

in python.withPackages(ps: [ps.foo])).passthru.pkgs.foo

Note the self = python.

@FRidh

This comment has been minimized.

Copy link
Member

commented Jul 5, 2019

I've updated the example in f1ff85e. There's not much else I think we can do here.

@FRidh FRidh removed the 0.kind: bug label Jul 5, 2019

vdemeester pushed a commit to vdemeester/nixpkgs that referenced this issue Jul 5, 2019

Docs Python: fix example on how to override the package set
Not passing in the newly created interpreter as `self` results in an
incorrect `passthru`. Solves NixOS#64334.
@adisbladis

This comment has been minimized.

Copy link
Member Author

commented Jul 5, 2019

Ok, updating the example is good enough :)
Thanks

@adisbladis adisbladis closed this Jul 5, 2019

FRidh added a commit that referenced this issue Jul 5, 2019

Docs Python: fix example on how to override the package set
Not passing in the newly created interpreter as `self` results in an
incorrect `passthru`. Solves #64334.

(cherry picked from commit f1ff85e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.