about summary refs log tree commit diff
path: root/pkgs/applications/science/physics/professor/default.nix
blob: c01e194034dd3962fe727db12a4298d4df933c03 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
{ lib
, stdenv
, fetchFromGitLab
, eigen
, makeWrapper
, python3
}:

stdenv.mkDerivation rec {
  pname = "professor";
  version = "2.4.2";

  src = fetchFromGitLab {
    owner = "hepcedar";
    repo = "professor";
    rev = "refs/tags/professor-2.4.2";
    hash = "sha256-z2Ub7SUTz4Hj3ajnzOV/QXZ+cH2v6zJv9UZM2M2y1Hg=";
    # workaround unpacking to case-sensitive filesystems
    postFetch = ''
      rm -rf $out/[Dd]ocker
    '';
  };

  postPatch = ''
    substituteInPlace Makefile \
      --replace-fail 'pip install ' 'pip install --prefix $(out) '
  '' + lib.optionalString stdenv.isDarwin ''
    substituteInPlace Makefile \
      --replace-fail '-shared -o' '-shared -install_name "$(out)/$@" -o'
  '';

  nativeBuildInputs = [
    python3.pkgs.cython
    python3.pkgs.pip
    python3.pkgs.setuptools
    python3.pkgs.wheel
    makeWrapper
  ];
  buildInputs = [
    python3
    eigen
  ];
  propagatedBuildInputs = with python3.pkgs; [
    iminuit
    numpy
    matplotlib
    yoda
  ];

  CPPFLAGS = [ "-I${eigen}/include/eigen3" ];
  PREFIX = placeholder "out";

  postInstall = ''
    for prog in "$out"/bin/*; do
      wrapProgram "$prog" --set PYTHONPATH "$PYTHONPATH:$(toPythonPath "$out")"
    done
  '';

  doInstallCheck = true;
  installCheckTarget = "check";

  meta = with lib; {
    description = "A tuning tool for Monte Carlo event generators";
    homepage = "https://professor.hepforge.org/";
    license = licenses.gpl3Only;
    maintainers = [ maintainers.veprbl ];
    platforms = platforms.unix;
  };
}