1{
2 lib,
3 stdenv,
4 fetchurl,
5 bash,
6 python3,
7 makeWrapper,
8}:
9
10stdenv.mkDerivation rec {
11 pname = "lhapdf";
12 version = "6.5.5";
13
14 src = fetchurl {
15 url = "https://www.hepforge.org/archive/lhapdf/LHAPDF-${version}.tar.gz";
16 sha256 = "sha256-ZB1eoJQreeREfhXlozSR/zxwMtcdYYEZk14UrSf146U=";
17 };
18
19 # The Apple SDK only exports locale_t from xlocale.h whereas glibc
20 # had decided that xlocale.h should be a part of locale.h
21 postPatch = lib.optionalString (stdenv.hostPlatform.isDarwin && stdenv.cc.isGNU) ''
22 substituteInPlace src/GridPDF.cc --replace '#include <locale>' '#include <xlocale.h>'
23 '';
24
25 nativeBuildInputs = [
26 bash
27 makeWrapper
28 ]
29 ++ lib.optionals (python3 != null && lib.versionAtLeast python3.version "3.10") [
30 python3.pkgs.cython
31 ];
32 buildInputs = [ python3 ];
33
34 configureFlags = lib.optionals (python3 == null) [ "--disable-python" ];
35
36 preBuild = lib.optionalString (python3 != null && lib.versionAtLeast python3.version "3.10") ''
37 rm wrappers/python/lhapdf.cpp
38 '';
39
40 strictDeps = true;
41
42 enableParallelBuilding = true;
43
44 passthru = {
45 pdf_sets = import ./pdf_sets.nix { inherit lib stdenv fetchurl; };
46 };
47
48 postInstall = ''
49 patchShebangs --build $out/bin/lhapdf-config
50 wrapProgram $out/bin/lhapdf --prefix PYTHONPATH : "$(toPythonPath "$out")"
51 '';
52
53 meta = with lib; {
54 description = "General purpose interpolator, used for evaluating Parton Distribution Functions from discretised data files";
55 license = licenses.gpl3;
56 homepage = "https://www.lhapdf.org";
57 platforms = platforms.unix;
58 maintainers = with maintainers; [ veprbl ];
59 };
60}