1{ lib, stdenv, fetchurl, fetchpatch, fastjet, fastjet-contrib, ghostscript, hepmc, imagemagick, less, python3, rsync, texliveBasic, yoda, which, makeWrapper }:
2
3stdenv.mkDerivation rec {
4 pname = "rivet";
5 version = "3.1.8";
6
7 src = fetchurl {
8 url = "https://www.hepforge.org/archive/rivet/Rivet-${version}.tar.bz2";
9 hash = "sha256-dbPz1BnKY4jR/S7A7afh+Q8yS5lszwWR9IpdLijczBM=";
10 };
11
12 latex = texliveBasic.withPackages (ps: with ps; [
13 collection-pstricks
14 collection-fontsrecommended
15 l3kernel
16 l3packages
17 mathastext
18 pgf
19 relsize
20 sansmath
21 sfmath
22 siunitx
23 xcolor
24 xkeyval
25 xstring
26 ]);
27
28 nativeBuildInputs = [ rsync makeWrapper ];
29 buildInputs = [ hepmc imagemagick python3 latex python3.pkgs.yoda ];
30 propagatedBuildInputs = [ fastjet fastjet-contrib ];
31
32 preConfigure = ''
33 substituteInPlace bin/rivet-build.in \
34 --replace 'num_jobs=$(getconf _NPROCESSORS_ONLN)' 'num_jobs=''${NIX_BUILD_CORES:-$(getconf _NPROCESSORS_ONLN)}' \
35 --replace 'which' '"${which}/bin/which"' \
36 --replace 'mycxx=' 'mycxx=${stdenv.cc}/bin/${if stdenv.cc.isClang or false then "clang++" else "g++"} #' \
37 --replace 'mycxxflags="' "mycxxflags=\"$NIX_CFLAGS_COMPILE $NIX_CXXSTDLIB_COMPILE $NIX_CFLAGS_LINK "
38 '';
39
40 preInstall = ''
41 substituteInPlace bin/make-plots \
42 --replace '"which"' '"${which}/bin/which"' \
43 --replace '"latex"' '"'$latex'/bin/latex"' \
44 --replace '"dvips"' '"'$latex'/bin/dvips"' \
45 --replace '"ps2pdf"' '"${ghostscript}/bin/ps2pdf"' \
46 --replace '"ps2eps"' '"${ghostscript}/bin/ps2eps"' \
47 --replace '"kpsewhich"' '"'$latex'/bin/kpsewhich"' \
48 --replace '"convert"' '"${imagemagick.out}/bin/convert"'
49 substituteInPlace bin/rivet \
50 --replace '"less"' '"${less}/bin/less"'
51 substituteInPlace bin/rivet-mkhtml \
52 --replace '"make-plots"' \"$out/bin/make-plots\" \
53 --replace '"rivet-cmphistos"' \"$out/bin/rivet-cmphistos\" \
54 --replace 'ch_cmd = [sys.executable, os.path.join(os.path.dirname(__file__),' 'ch_cmd = [('
55 '';
56
57 configureFlags = [
58 "--with-fastjet=${fastjet}"
59 "--with-yoda=${yoda}"
60 ] ++ (if lib.versions.major hepmc.version == "3" then [
61 "--with-hepmc3=${hepmc}"
62 ] else [
63 "--with-hepmc=${hepmc}"
64 ]);
65
66 enableParallelBuilding = true;
67
68 postInstall = ''
69 for prog in "$out"/bin/*; do
70 wrapProgram "$prog" --set PYTHONPATH $PYTHONPATH:$(toPythonPath "$out")
71 done
72 '';
73
74 meta = with lib; {
75 description = "A framework for comparison of experimental measurements from high-energy particle colliders to theory predictions";
76 license = licenses.gpl3;
77 homepage = "https://rivet.hepforge.org";
78 platforms = platforms.unix;
79 maintainers = with maintainers; [ veprbl ];
80 };
81}