Dear all,
i am trying to write some nix derivations for some computational chemistry software, including some python applications and libraries. Namely i have a problem with an application, that is written in a mixture of C++ and python, called Psi4.
I have written a derivation for some of its python dependencies, e.g. for the python module qcelemental
{ buildPythonPackage, lib, fetchPypi
# Other dependencies
, cacert
# Python dependencies
, numpy
, pydantic
, pint
, networkx
, pytestrunner
, pytestcov
}:
buildPythonPackage rec {
# Skipping the rest here for clarity
propagatedBuildInputs = [
numpy
pydantic
pint
networkx
cacert
];
}
and i call it from my default.nix
as
let
nixpkgs = import <nixpkgs> { config = packageOverrides; };
allPkgs = nixpkgs // pkgs;
callPackage = nixpkgs.callPackage;
pkgs = with allPkgs; rec {
psi4 = python3Packages.callPackage ./pkgs/apps/psi4/default.nix { inherit qcelemental; };
qcelemental = python3Packages.callPackage ./pkgs/libs/python/qcelemental/default.nix { inherit pydantic; pint = pint-0_10; };
# ...
}
in pkgs
The first thing that puzzles me, is that i can’t import the qcelemental
module from a nix-shell
, where my shell.nix
something simple as :
let pkgs = import ./default.nix;
in pkgs.qcelemental
A python interpreter within that nix-shell
only tells me, that a qcelemental
package could not be found. Its propagatedBuildInputs
can be found without any problems and a nix-shell -p python3Packages.numpy
for example also behaves as i would expect, allowing me to import numpy.
Now if i use my qcelemental
derivation as a propagatedBuildInput
for my Psi4 derivation
{ stdenv, buildPythonApplication, buildPackages, fetchFromGitHub
# Build time dependencies
, cmake
, perl
, gfortran
, makeWrapper
# Runtime dependencies
, python3
, mkl
, gau2grid
, libint
, libxc
, qcelemental
}:
let
python = python3.withPackages (ps : with ps; [ pybind11 ]);
in stdenv.mkDerivation rec {
pname = "psi4";
version = "1.3.2";
nativeBuildInputs = [
cmake
perl
gfortran
];
buildInputs = [
gau2grid
libint
libxc
mkl
];
propagatedBuildInputs = [
python
qcelemental
];
# Rest skipped
}
and try this one in a nix-shell
, the import of qcelemental
in a python interpreter works, and the Psi4 executable also works fine. However, installing the psi4 derivation with nix-env -f default.nix -iA psi4
gives a program, that cannot find the qcelemental
module (and i suspect also other python modules).
So i am puzzled by two things:
- Why are python packages available in a
nix-shell
, that were given with-p
but not from ashell.nix
? - How would i tell a mixed application of C++ and Python like Psi4, how and where to find all its python runtime modules, when building with
stdenv.mkDerivation
?
Thank you for any help and suggestions in advance
Best wishes
Phillip