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