emacsPackages.lsp-bridge: 0-unstable-2025-01-11 -> 0-unstable-2025-01-22 (#376531)
[NixPkgs.git] / pkgs / development / libraries / eccodes / default.nix
blob0fc52796a054532533721bb0be8b5065e525081e
2   fetchurl,
3   lib,
4   stdenv,
5   cmake,
6   netcdf,
7   openjpeg,
8   libaec,
9   libpng,
10   gfortran,
11   perl,
12   enablePython ? false,
13   pythonPackages,
14   enablePosixThreads ? false,
15   enableOpenMPThreads ? false,
18 stdenv.mkDerivation rec {
19   pname = "eccodes";
20   version = "2.39.0";
22   src = fetchurl {
23     url = "https://confluence.ecmwf.int/download/attachments/45757960/eccodes-${version}-Source.tar.gz";
24     hash = "sha256-DE10ZwCsxJr5yHiSXxsmvdQkQ/98LXxnbesrq7aEevs=";
25   };
27   postPatch = ''
28     substituteInPlace cmake/FindOpenJPEG.cmake --replace openjpeg-2.1 ${openjpeg.incDir}
30     # https://github.com/ecmwf/ecbuild/issues/40
31     substituteInPlace cmake/ecbuild_config.h.in \
32       --replace @CMAKE_INSTALL_PREFIX@/@INSTALL_LIB_DIR@ @eccodes_FULL_INSTALL_LIB_DIR@ \
33       --replace @CMAKE_INSTALL_PREFIX@/@INSTALL_BIN_DIR@ @eccodes_FULL_INSTALL_BIN_DIR@
34     substituteInPlace cmake/pkg-config.pc.in \
35       --replace '$'{prefix}/@INSTALL_LIB_DIR@ @eccodes_FULL_INSTALL_LIB_DIR@ \
36       --replace '$'{prefix}/@INSTALL_INCLUDE_DIR@ @eccodes_FULL_INSTALL_INCLUDE_DIR@ \
37       --replace '$'{prefix}/@INSTALL_BIN_DIR@ @eccodes_FULL_INSTALL_BIN_DIR@
38     substituteInPlace cmake/ecbuild_install_project.cmake \
39       --replace '$'{CMAKE_INSTALL_PREFIX}/'$'{INSTALL_INCLUDE_DIR} '$'{'$'{PROJECT_NAME}_FULL_INSTALL_INCLUDE_DIR}
40   '';
42   nativeBuildInputs = [
43     cmake
44     gfortran
45     perl
46   ];
48   buildInputs = [
49     netcdf
50     openjpeg
51     libaec
52     libpng
53   ];
55   propagatedBuildInputs = lib.optionals enablePython [
56     pythonPackages.python
57     pythonPackages.numpy
58   ];
60   cmakeFlags = [
61     "-DENABLE_PYTHON=${if enablePython then "ON" else "OFF"}"
62     "-DENABLE_PNG=ON"
63     "-DENABLE_ECCODES_THREADS=${if enablePosixThreads then "ON" else "OFF"}"
64     "-DENABLE_ECCODES_OMP_THREADS=${if enableOpenMPThreads then "ON" else "OFF"}"
65   ];
67   doCheck = true;
69   # Only do tests that don't require downloading 120MB of testdata
70   checkPhase = ''
71     ctest -R "eccodes_t_(definitions|calendar|unit_tests|md5|uerra|grib_2nd_order_numValues|julian)" -VV
72   '';
74   meta = with lib; {
75     homepage = "https://confluence.ecmwf.int/display/ECC/";
76     license = licenses.asl20;
77     maintainers = with maintainers; [ ];
78     platforms = platforms.unix;
79     description = "ECMWF library for reading and writing GRIB, BUFR and GTS abbreviated header";
80   };