nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchurl,
5 cmake,
6 coreutils,
7 python,
8 root,
9}:
10
11let
12 pythonVersion = with lib.versions; "${major python.version}${minor python.version}";
13 withPython = python != null;
14 # ensure that root is built with the same python interpreter, as it links against numpy
15 root_py = if withPython then root.override { python3 = python; } else root;
16in
17
18stdenv.mkDerivation rec {
19 pname = "hepmc3";
20 version = "3.3.1";
21
22 src = fetchurl {
23 url = "http://hepmc.web.cern.ch/hepmc/releases/HepMC3-${version}.tar.gz";
24 sha256 = "sha256-CCQBYLDyjcMpOqTWHOZeLWfNWXrPb6ykOfLkZiX355M=";
25 };
26
27 nativeBuildInputs = [
28 cmake
29 ]
30 ++ lib.optional withPython python.pkgs.pythonImportsCheckHook;
31
32 buildInputs = [
33 root_py
34 ]
35 ++ lib.optional withPython python;
36
37 # error: invalid version number in 'MACOSX_DEPLOYMENT_TARGET=11.0'
38 preConfigure =
39 lib.optionalString
40 (stdenv.hostPlatform.isDarwin && lib.versionAtLeast stdenv.hostPlatform.darwinMinVersion "11")
41 ''
42 MACOSX_DEPLOYMENT_TARGET=10.16
43 '';
44
45 cmakeFlags = [
46 "-DHEPMC3_CXX_STANDARD=17"
47 "-DHEPMC3_ENABLE_PYTHON=${if withPython then "ON" else "OFF"}"
48 ]
49 ++ lib.optionals withPython [
50 "-DHEPMC3_PYTHON_VERSIONS=${if python.isPy3k then "3.X" else "2.X"}"
51 "-DHEPMC3_Python_SITEARCH${pythonVersion}=${placeholder "out"}/${python.sitePackages}"
52 ];
53
54 postInstall = ''
55 substituteInPlace "$out"/bin/HepMC3-config \
56 --replace-fail '$(greadlink' '$(${coreutils}/bin/readlink' \
57 --replace-fail '$(readlink' '$(${coreutils}/bin/readlink'
58 '';
59
60 pythonImportsCheck = [ "pyHepMC3" ];
61
62 meta = {
63 description = "HepMC package is an object oriented, C++ event record for High Energy Physics Monte Carlo generators and simulation";
64 mainProgram = "HepMC3-config";
65 license = lib.licenses.gpl3;
66 homepage = "http://hepmc.web.cern.ch/hepmc/";
67 platforms = lib.platforms.unix;
68 maintainers = with lib.maintainers; [ veprbl ];
69 };
70}