Cannot link against Python


I’m creating a derivation for qiskit-aer, a quantum computer simulator.
qiskit-aer is written in C++ and compiled using CMake.
Also, it has a Cython wrapper for using it from Python.
Since this module requires to be linked against Python, I used NIX_CFLAGS_COMPILE and NIX_LDFLAGS as follows:

{ stdenv
, isPy3k
, buildPythonPackage
, fetchFromGitHub
, cmake
, blas
, liblapack
, scikit-build
, cython
, python

buildPythonPackage rec {
  pname = "qiskit-aer";
  version = "0.1.1";

  disabled = !isPy3k;

  src = fetchFromGitHub {
    owner = "Qiskit";
    repo = "qiskit-aer";
    rev = "21fdd7e7503dc8ac7dfaee24b927f26d1eff42f8";
    sha256 = "1p4w1jg6sl9xvmp98nrn5s6drp1rcl67vzi5xdh639kf498y49nz";

  buildInputs = [



I can compile the sources, but link fails because Python library is missing.
The error message is:

[ 45%] Linking CXX shared module
/nix/store/3xwc1ip20b0p68sxqbjjll0va4pv5hbv-binutils-2.30/bin/ld: cannot find -lpython3.7m
collect2: error: ld returned 1 exit status

although I have in the directory I specified:

[pan@pan-nixos:~/nixpkgs]$ ls /nix/store/6lm4gi5iv8fbf1b1mm6g3gfnnv63f1gn-python3-3.7.1/lib/  pkgconfig  python3.7

How to build a package that link against Python?

If you want to test the code, you can fetch the following branch (qiskit-0.7.1):

Since qiskit-aer uses scikit-build for invoking cmake during the setup, I included scikit-build.


It seems fixes this issue.
After I cherry-picked it and, I can build the package.