1{ lib, stdenv
2, fetchurl, unzip
3, hdf5
4, libxml2
5, m4
6, curl # for DAP
7, removeReferencesTo
8}:
9
10let
11 inherit (hdf5) mpiSupport mpi;
12in stdenv.mkDerivation rec {
13 pname = "netcdf" + lib.optionalString mpiSupport "-mpi";
14 version = "4.9.0";
15
16 src = fetchurl {
17 url = "https://downloads.unidata.ucar.edu/netcdf-c/${version}/netcdf-c-${version}.tar.gz";
18 hash = "sha256-TJVgIrecCOXhTu6N9RsTwo5hIcK35/qtwhs3WUlAC0k=";
19 };
20
21 postPatch = ''
22 patchShebangs .
23
24 # this test requires the net
25 for a in ncdap_test/Makefile.am ncdap_test/Makefile.in; do
26 substituteInPlace $a --replace testurl.sh " "
27 done
28 '';
29
30 nativeBuildInputs = [ m4 removeReferencesTo ];
31
32 buildInputs = [
33 curl
34 hdf5
35 libxml2
36 mpi
37 ];
38
39 passthru = {
40 inherit mpiSupport mpi;
41 };
42
43 configureFlags = [
44 "--enable-netcdf-4"
45 "--enable-dap"
46 "--enable-shared"
47 "--disable-dap-remote-tests"
48 ]
49 ++ (lib.optionals mpiSupport [ "--enable-parallel-tests" "CC=${mpi}/bin/mpicc" ]);
50
51 disallowedReferences = [ stdenv.cc ];
52
53 postFixup = ''
54 remove-references-to -t ${stdenv.cc} "$(readlink -f $out/lib/libnetcdf.settings)"
55 '';
56
57 doCheck = !(mpiSupport || (stdenv.isDarwin && stdenv.isAarch64));
58 checkInputs = [ unzip ];
59
60 preCheck = ''
61 export HOME=$TEMP
62 '';
63
64 meta = {
65 description = "Libraries for the Unidata network Common Data Format";
66 platforms = lib.platforms.unix;
67 homepage = "https://www.unidata.ucar.edu/software/netcdf/";
68 changelog = "https://docs.unidata.ucar.edu/netcdf-c/${version}/RELEASE_NOTES.html";
69 license = lib.licenses.bsd3;
70 };
71}