Nixpkgs: adding python package in overlay via callPackage

Created on 10 Oct 2017  Â·  3Comments  Â·  Source: NixOS/nixpkgs

Issue description

In a similar spirit as https://github.com/NixOS/nixpkgs/issues/26487 I am trying to test my python packages from an overlay (In this peculiar case it's more practical for me to do it from an overlay than to fork nixpkgs). So in my otherwise (working) overlay, I've added

  pythonPackages = super.pythonPackages.override {
     # Careful, we're using a different self and super here!
    packageOverrides = self: super: {
        pygccxml =  super.callPackage ../pygccxml.nix {
        # pkgs = super.pkgs;
        # pythonPackages = self.pkgs.python3Packages;
      };
    };
  };

Then when I run a nix-shell, I get:

nix-shell -p 'python.withPackages(ps: [ ps.pygccxml] )' --show-trace                        
error: while evaluating the attribute ‘buildInputs’ of the derivation ‘shell’ at /home/teto/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:98:11:
while evaluating the attribute ‘pkgs’ of the derivation ‘python-2.7.14-env’ at /home/teto/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:98:11:
while evaluating ‘closePropagation’ at /home/teto/nixpkgs/lib/deprecated.nix:228:22, called from /home/teto/nixpkgs/pkgs/development/interpreters/python/wrapper.nix:11:13:
while evaluating ‘uniqList’ at /home/teto/nixpkgs/lib/deprecated.nix:159:14, called from /home/teto/nixpkgs/lib/deprecated.nix:228:29:
while evaluating ‘go’ at /home/teto/nixpkgs/lib/deprecated.nix:160:18, called from /home/teto/nixpkgs/lib/deprecated.nix:166:8:
while evaluating ‘innerClosePropagation’ at /home/teto/nixpkgs/lib/deprecated.nix:211:32, called from /home/teto/nixpkgs/lib/deprecated.nix:228:52:
attribute ‘pygccxml’ missing, at (string):1:92

content of pygccxml.nix:

{ stdenv, pkgs, fetchPypi, pythonPackages }:

pythonPackages.buildPythonPackage rec {
  name = "${pname}-${version}";
  pname = "pygccxml";
  version = "1.9.1";

  src = fetchPypi {
    inherit pname version;
    sha256 = "0x1p62ff7ggb172rjr6sbdrjh1gl3ck3bwxsqlsix8i5wycwvnmv";
  };

  propagatedBuildInputs = [ pkgs.castxml ];
  # buildInputs = [ setuptools_scm pytest pkgs.glibcLocales ];

  checkPhase = ''
    # py.test
  '';

  meta = with stdenv.lib; {
    homepage = https://github.com/gccxml/pygccxml;
    description = "Python package for easy C++ declarations navigation";
    license = licenses.boost;
    maintainers = with maintainers; [ teto ];
  };
}

Technical details

nixos-version=18.03.git.56a5c5f (Impala)
nix version: nix-env (Nix) 1.11.15
Nixpkgs version: "18.03.git.56a5c5fa42"
sandboxing disabled

question

Most helpful comment

I had seen the doc but had missed the pythonPackages = python.pkgs;
This works

  python = super.python.override {
     # Careful, we're using a different self and super here!
    packageOverrides = self: super: {
      # if (super.pkgs ? pygccxml) then null else
        pygccxml =  super.callPackage ../pygccxml.nix {
        # pkgs = super.pkgs;
        # pythonPackages = self.pkgs.python3Packages;
      };
    };
  };

  pythonPackages = python.pkgs;

All 3 comments

Check section 9.11.3.2. How to override a Python package? of the Nixpkgs manual.

I had seen the doc but had missed the pythonPackages = python.pkgs;
This works

  python = super.python.override {
     # Careful, we're using a different self and super here!
    packageOverrides = self: super: {
      # if (super.pkgs ? pygccxml) then null else
        pygccxml =  super.callPackage ../pygccxml.nix {
        # pkgs = super.pkgs;
        # pythonPackages = self.pkgs.python3Packages;
      };
    };
  };

  pythonPackages = python.pkgs;

@teto your example can be simplified with this PR https://github.com/NixOS/nixpkgs/pull/54266#issuecomment-455592425

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lverns picture lverns  Â·  3Comments

ghost picture ghost  Â·  3Comments

copumpkin picture copumpkin  Â·  3Comments

domenkozar picture domenkozar  Â·  3Comments

ob7 picture ob7  Â·  3Comments