1{
2 lib,
3 stdenv,
4 fetchurl,
5 boost,
6 lhapdf,
7 ncurses,
8 perl,
9 python ? null,
10 swig,
11 yoda,
12 zlib,
13 withPython ? false,
14}:
15
16stdenv.mkDerivation rec {
17 pname = "fastnlo-toolkit";
18 version = "2.5.0-2826";
19
20 src = fetchurl {
21 url = "https://fastnlo.hepforge.org/code/v25/fastnlo_toolkit-${version}.tar.gz";
22 hash = "sha256-7aIMYCOkHC/17CHYiEfrxvtSJxTDivrS7BQ32cGiEy0=";
23 };
24
25 postPatch = ''
26 substituteInPlace py-compile \
27 --replace-fail "import sys, os, py_compile, imp" "import sys, os, py_compile, importlib" \
28 --replace-fail "imp." "importlib." \
29 --replace-fail "hasattr(imp" "hasattr(importlib"
30 '';
31
32 patches = [
33 # Compatibility with YODA 2.x
34 ./yoda2_support.patch
35 ];
36
37 nativeBuildInputs = [
38 lhapdf # lhapdf-config
39 yoda # yoda-config
40 ]
41 ++ lib.optional withPython python;
42
43 buildInputs = [
44 boost
45 lhapdf
46 yoda
47 ]
48 ++ lib.optional withPython python
49 ++ lib.optional (withPython && python.isPy3k) ncurses;
50
51 propagatedNativeBuildInputs = lib.optional withPython [ swig ];
52 propagatedBuildInputs = [
53 zlib
54 ]
55 ++ lib.optional withPython [
56 python.pkgs.distutils
57 ];
58
59 preConfigure = ''
60 substituteInPlace ./fastnlotoolkit/Makefile.in \
61 --replace "-fext-numeric-literals" ""
62
63 # disable test that fails due to strict floating-point number comparison
64 echo "#!/usr/bin/env perl" > check/fnlo-tk-stattest.pl.in
65 chmod +x check/fnlo-tk-stattest.pl.in
66 '';
67
68 configureFlags = [
69 "--with-yoda=${yoda}"
70 ]
71 ++ lib.optional withPython "--enable-pyext";
72
73 strictDeps = true;
74
75 enableParallelBuilding = true;
76
77 doCheck = true;
78 nativeCheckInputs = [
79 perl
80 lhapdf.pdf_sets.CT10nlo
81 ];
82 preCheck = ''
83 patchShebangs --build check
84 '';
85 enableParallelChecking = false;
86
87 # None of our currently packaged versions of swig are C++17-friendly
88 # Use a workaround from https://github.com/swig/swig/issues/1538
89 env.CXXFLAGS = "-D_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES";
90
91 meta = with lib; {
92 homepage = "http://fastnlo.hepforge.org";
93 description = "Fast pQCD calculations for hadron-induced processes";
94 longDescription = ''
95 The fastNLO project provides computer code to create and evaluate fast
96 interpolation tables of pre-computed coefficients in perturbation theory
97 for observables in hadron-induced processes.
98
99 This allows fast theory predictions of these observables for arbitrary
100 parton distribution functions (of regular shape), renormalization or
101 factorization scale choices, and/or values of alpha_s(Mz) as e.g. needed
102 in PDF fits or in systematic studies. Very time consuming complete
103 recalculations are thus avoided.
104 '';
105 license = licenses.gpl3Plus;
106 maintainers = with maintainers; [ veprbl ];
107 platforms = platforms.unix;
108 broken = stdenv.hostPlatform.isDarwin;
109 };
110}