Pantheon updates 2024-12-13 (#364951)
[NixPkgs.git] / pkgs / development / libraries / physics / rivet / default.nix
blobadf5ae595efe73c089c6d65980efa821a54f7c53
2   lib,
3   stdenv,
4   fetchurl,
5   fastjet,
6   fastjet-contrib,
7   ghostscript,
8   hdf5,
9   hepmc3,
10   highfive,
11   imagemagick,
12   less,
13   pkg-config,
14   python3,
15   rsync,
16   texliveBasic,
17   yoda,
18   which,
19   makeWrapper,
22 stdenv.mkDerivation rec {
23   pname = "rivet";
24   version = "4.0.2";
26   src = fetchurl {
27     url = "https://www.hepforge.org/archive/rivet/Rivet-${version}.tar.bz2";
28     hash = "sha256-ZaOzb0K/94LtJ2eTDmaeCbFAiZYF15cvyPd3hbSogsA=";
29   };
31   latex = texliveBasic.withPackages (
32     ps: with ps; [
33       collection-pstricks
34       collection-fontsrecommended
35       l3kernel
36       l3packages
37       mathastext
38       pgf
39       relsize
40       sansmath
41       sfmath
42       siunitx
43       xcolor
44       xkeyval
45       xstring
46     ]
47   );
49   nativeBuildInputs = [
50     rsync
51     makeWrapper
52     pkg-config
53   ];
54   buildInputs = [
55     hepmc3
56     highfive
57     imagemagick
58     python3
59     latex
60     python3.pkgs.yoda
61   ];
62   propagatedBuildInputs = [
63     hdf5
64     fastjet
65     fastjet-contrib
66   ];
68   preConfigure = ''
69     substituteInPlace configure \
70       --replace-fail 'if test $HEPMC_VERSION -le 310; then' 'if false; then'
71     substituteInPlace bin/rivet-build.in \
72       --replace-fail 'num_jobs=$(getconf _NPROCESSORS_ONLN)' 'num_jobs=''${NIX_BUILD_CORES:-$(getconf _NPROCESSORS_ONLN)}' \
73       --replace-fail 'which' '"${which}/bin/which"' \
74       --replace-fail 'mycxx=' 'mycxx=${stdenv.cc}/bin/${
75         if stdenv.cc.isClang or false then "clang++" else "g++"
76       }  #' \
77       --replace-fail 'mycxxflags="' "mycxxflags=\"$NIX_CFLAGS_COMPILE $NIX_CXXSTDLIB_COMPILE $NIX_CFLAGS_LINK "
78   '';
80   preInstall = ''
81     substituteInPlace bin/make-plots \
82       --replace-fail '"which"' '"${which}/bin/which"' \
83       --replace-fail '"latex"' '"'$latex'/bin/latex"' \
84       --replace-fail '"dvips"' '"'$latex'/bin/dvips"' \
85       --replace-fail '"ps2pdf"' '"${ghostscript}/bin/ps2pdf"' \
86       --replace-fail '"ps2eps"' '"${ghostscript}/bin/ps2eps"' \
87       --replace-fail '"kpsewhich"' '"'$latex'/bin/kpsewhich"' \
88       --replace-fail '"convert"' '"${imagemagick.out}/bin/convert"'
89     substituteInPlace bin/rivet \
90       --replace-fail '"less"' '"${less}/bin/less"'
91     substituteInPlace bin/rivet-mkhtml-tex \
92       --replace-fail '"make-plots"' \"$out/bin/make-plots\" \
93       --replace-fail '"rivet-cmphistos"' \"$out/bin/rivet-cmphistos\" \
94       --replace-fail 'ch_cmd = [sys.executable, os.path.join(os.path.dirname(__file__),' 'ch_cmd = [('
95   '';
97   configureFlags = [
98     "--with-fastjet=${fastjet}"
99     "--with-yoda=${yoda}"
100     "--with-hepmc3=${hepmc3}"
101     "--with-highfive=${highfive}"
102   ];
104   enableParallelBuilding = true;
106   postInstall = ''
107     for prog in "$out"/bin/*; do
108       wrapProgram "$prog" --set PYTHONPATH $PYTHONPATH:$(toPythonPath "$out")
109     done
110   '';
112   meta = with lib; {
113     description = "Framework for comparison of experimental measurements from high-energy particle colliders to theory predictions";
114     license = licenses.gpl3;
115     homepage = "https://rivet.hepforge.org";
116     platforms = platforms.unix;
117     maintainers = with maintainers; [ veprbl ];
118   };