Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib, stdenv, fetchurl, fetchpatch, python, makeWrapper }: 2 3stdenv.mkDerivation rec { 4 pname = "lhapdf"; 5 version = "6.5.3"; 6 7 src = fetchurl { 8 url = "https://www.hepforge.org/archive/lhapdf/LHAPDF-${version}.tar.gz"; 9 sha256 = "sha256-V0Nc1pXilwZdU+ab0pCQdlyTSTa2qXX/jFWXZvIjA1k="; 10 }; 11 12 patches = [ 13 # avoid silent compilation failures 14 (fetchpatch { 15 name = "lhapdf-propagate_returncode.patch"; 16 url = "https://gitlab.com/hepcedar/lhapdf/-/commit/2806ac795c7e4a69281d9c2a6a8bba5423f37e74.diff"; 17 hash = "sha256-j8txlt0n5gpUy9zeuWKx+KRXL3HMMaGcwOxr908966k="; 18 }) 19 20 # workaround "ld: -stack_size option can only be used when linking a main executable" on darwin 21 (fetchpatch { 22 name = "lhapdf-Wl_stack_size.patch"; 23 url = "https://gitlab.com/hepcedar/lhapdf/-/commit/463764d6613837b6ab57ecaf13bc61be2349e5e4.diff"; 24 hash = "sha256-AbDs7gtU5HsJG5n/solMzu2bjX1juxfUIqIt5KmNffU="; 25 }) 26 ]; 27 28 # The Apple SDK only exports locale_t from xlocale.h whereas glibc 29 # had decided that xlocale.h should be a part of locale.h 30 postPatch = lib.optionalString (stdenv.isDarwin && stdenv.cc.isGNU) '' 31 substituteInPlace src/GridPDF.cc --replace '#include <locale>' '#include <xlocale.h>' 32 ''; 33 34 nativeBuildInputs = [ makeWrapper ] 35 ++ lib.optionals (python != null && lib.versionAtLeast python.version "3.10") [ python.pkgs.cython ]; 36 buildInputs = [ python ]; 37 38 configureFlags = lib.optionals (python == null) [ "--disable-python" ]; 39 40 preBuild = lib.optionalString (python != null && lib.versionAtLeast python.version "3.10") '' 41 rm wrappers/python/lhapdf.cpp 42 ''; 43 44 enableParallelBuilding = true; 45 46 passthru = { 47 pdf_sets = import ./pdf_sets.nix { inherit lib stdenv fetchurl; }; 48 }; 49 50 postInstall = '' 51 wrapProgram $out/bin/lhapdf --prefix PYTHONPATH : "$(toPythonPath "$out")" 52 ''; 53 54 meta = with lib; { 55 description = "A general purpose interpolator, used for evaluating Parton Distribution Functions from discretised data files"; 56 license = licenses.gpl2; 57 homepage = "http://lhapdf.hepforge.org"; 58 platforms = platforms.unix; 59 maintainers = with maintainers; [ veprbl ]; 60 }; 61}