linux_xanmod: 5.11.14 -> 5.11.15
[NixPkgs.git] / pkgs / development / libraries / eccodes / default.nix
blob1050490a220b68cba5167b0e490d83227ea17627
1 { fetchurl, lib, stdenv
2 , cmake, netcdf, openjpeg, libpng, gfortran
3 , enablePython ? false, pythonPackages
4 , enablePosixThreads ? false
5 , enableOpenMPThreads ? false}:
6 with lib;
7 stdenv.mkDerivation rec {
8   pname = "eccodes";
9   version = "2.12.5";
11   src = fetchurl {
12     url = "https://confluence.ecmwf.int/download/attachments/45757960/eccodes-${version}-Source.tar.gz";
13     sha256 = "0576fccng4nvmq5gma1nb1v00if5cwl81w4nv5zkb80q5wicn50c";
14   };
16   postPatch = ''
17     substituteInPlace cmake/FindOpenJPEG.cmake --replace openjpeg-2.1 ${openjpeg.incDir}
18   '';
20   nativeBuildInputs = [ cmake ];
22   buildInputs = [ netcdf
23                   openjpeg
24                   libpng
25                   gfortran
26                 ];
27   propagatedBuildInputs = optionals enablePython [
28                   pythonPackages.python
29                   pythonPackages.numpy
30                 ];
32   cmakeFlags = [ "-DENABLE_PYTHON=${if enablePython then "ON" else "OFF"}"
33                  "-DENABLE_PNG=ON"
34                  "-DENABLE_ECCODES_THREADS=${if enablePosixThreads then "ON" else "OFF"}"
35                  "-DENABLE_ECCODES_OMP_THREADS=${if enableOpenMPThreads then "ON" else "OFF"}"
36                ];
38   doCheck = true;
40   # Only do tests that don't require downloading 120MB of testdata
41   checkPhase = lib.optionalString (stdenv.isDarwin) ''
42     substituteInPlace "tests/include.sh" --replace "set -ea" "set -ea; export DYLD_LIBRARY_PATH=$(pwd)/lib"
43   '' + ''
44     ctest -R "eccodes_t_(definitions|calendar|unit_tests|md5|uerra|grib_2nd_order_numValues|julian)" -VV
45   '';
47   meta = {
48     homepage = "https://confluence.ecmwf.int/display/ECC/";
49     license = licenses.asl20;
50     maintainers = with maintainers; [ knedlsepp ];
51     platforms = platforms.unix;
52     description = "ECMWF library for reading and writing GRIB, BUFR and GTS abbreviated header";
53   };