1 { lib, stdenv, fetchurl, cmake, coreutils, python, root }:
4 pythonVersion = with lib.versions; "${major python.version}${minor python.version}";
5 withPython = python != null;
6 # ensure that root is built with the same python interpreter, as it links against numpy
7 root_py = if withPython then root.override { inherit python; } else root;
10 stdenv.mkDerivation rec {
15 url = "http://hepmc.web.cern.ch/hepmc/releases/HepMC3-${version}.tar.gz";
16 sha256 = "sha256-zQ91yA91VJxZzCqCns52Acd96Xyypat1eQysjh1YUDI=";
19 nativeBuildInputs = [ cmake ];
20 buildInputs = [ root_py ]
21 ++ lib.optional withPython python;
24 "-DHEPMC3_ENABLE_PYTHON=${if withPython then "ON" else "OFF"}"
25 ] ++ lib.optionals withPython [
26 "-DHEPMC3_PYTHON_VERSIONS=${if python.isPy3k then "3.X" else "2.X"}"
27 "-DHEPMC3_Python_SITEARCH${pythonVersion}=${placeholder "out"}/${python.sitePackages}"
31 substituteInPlace "$out"/bin/HepMC3-config \
32 --replace 'greadlink' '${coreutils}/bin/readlink' \
33 --replace 'readlink' '${coreutils}/bin/readlink'
36 doInstallCheck = withPython;
37 # prevent nix from trying to dereference a null python
38 installCheckPhase = lib.optionalString withPython ''
39 PYTHONPATH=${placeholder "out"}/${python.sitePackages} python -c 'import pyHepMC3'
43 description = "The HepMC package is an object oriented, C++ event record for High Energy Physics Monte Carlo generators and simulation";
44 license = licenses.gpl3;
45 homepage = "http://hepmc.web.cern.ch/hepmc/";
46 platforms = platforms.unix;
47 maintainers = with maintainers; [ veprbl ];