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