summary refs log tree commit diff
path: root/pkgs/applications/science/physics/xfitter/default.nix
blob: 2be61538788937baadce3a645b49ba3bf026a73a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
{ lib
, stdenv
, fetchurl
, apfel
, apfelgrid
, applgrid
, blas
, ceres-solver
, cmake
, gfortran
, gsl
, lapack
, lhapdf
, libtirpc
, libyaml
, libyamlcpp
, pkg-config
, qcdnum
, root
, zlib
, memorymappingHook, memstreamHook
}:

stdenv.mkDerivation rec {
  pname = "xfitter";
  version = "2.2.0";

  src = fetchurl {
    name = "${pname}-${version}.tgz";
    url = "https://www.xfitter.org/xFitter/xFitter/DownloadPage?action=AttachFile&do=get&target=${pname}-${version}.tgz";
    sha256 = "sha256-ZHIQ5hOY+k0/wmpE0o4Po+RZ4MkVMk+bK1Rc6eqwwH0=";
  };

  preConfigure = ''
    substituteInPlace CMakeLists.txt \
      --replace "-fallow-argument-mismatch" ""
  '';

  nativeBuildInputs = [ cmake gfortran pkg-config ];
  buildInputs =
    [ apfel blas ceres-solver lhapdf lapack libyaml root qcdnum gsl libyamlcpp zlib ]
    ++ lib.optionals ("5" == lib.versions.major root.version) [ apfelgrid applgrid ]
    ++ lib.optionals (stdenv.system == "x86_64-darwin") [ memorymappingHook memstreamHook ]
    ++ lib.optional (stdenv.hostPlatform.libc == "glibc") libtirpc
    ;

  NIX_CFLAGS_COMPILE = lib.optional (stdenv.hostPlatform.libc == "glibc") "-I${libtirpc.dev}/include/tirpc";
  NIX_LDFLAGS = lib.optional (stdenv.hostPlatform.libc == "glibc") "-ltirpc";

  # workaround wrong library IDs
  postInstall = lib.optionalString stdenv.isDarwin ''
    ln -sv "$out/lib/xfitter/"* "$out/lib/"
  '';

  meta = with lib; {
    description = "The xFitter project is an open source QCD fit framework ready to extract PDFs and assess the impact of new data";
    license     = licenses.gpl3;
    homepage    = "https://www.xfitter.org/xFitter";
    platforms   = platforms.unix;
    maintainers = with maintainers; [ veprbl ];
  };
}