1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
{
lib,
stdenv,
fetchurl,
unzip,
hdf5,
bzip2,
libzip,
zstd,
szipSupport ? hdf5.szipSupport,
libaec,
libxml2,
m4,
curl, # for DAP
removeReferencesTo,
}:
let
inherit (hdf5) mpiSupport mpi;
in
stdenv.mkDerivation (finalAttrs: {
pname = "netcdf" + lib.optionalString mpiSupport "-mpi";
version = "4.10.1";
src = fetchurl {
url = "https://downloads.unidata.ucar.edu/netcdf-c/${finalAttrs.version}/netcdf-c-${finalAttrs.version}.tar.gz";
hash = "sha256-2ztp/0pe4afXmlw2Zk0hKLdSwmbpZjafz3MR7F+SdWQ=";
};
postPatch = ''
patchShebangs .
# this test requires the net
for a in ncdap_test/Makefile.am ncdap_test/Makefile.in; do
substituteInPlace $a --replace testurl.sh " "
done
# Prevent building the tests from prepending `#!/bin/bash` and wiping out the patched shenbangs.
substituteInPlace nczarr_test/Makefile.in \
--replace '#!/bin/bash' '${stdenv.shell}'
'';
nativeBuildInputs = [
m4
removeReferencesTo
libxml2 # xml2-config
];
buildInputs = [
curl
hdf5
libxml2
bzip2
libzip
zstd
]
++ lib.optional szipSupport libaec
++ lib.optional mpiSupport mpi;
strictDeps = true;
passthru = {
inherit mpiSupport mpi;
};
env.NIX_CFLAGS_COMPILE =
# Suppress incompatible function pointer errors when building with newer versions of clang 16.
# tracked upstream here: https://github.com/Unidata/netcdf-c/issues/2715
lib.optionalString stdenv.cc.isClang "-Wno-error=incompatible-function-pointer-types";
configureFlags = [
"--enable-netcdf-4"
"--enable-dap"
"--enable-shared"
"--disable-dap-remote-tests"
"--with-plugin-dir=${placeholder "out"}/lib/hdf5-plugins"
]
++ (lib.optionals mpiSupport [
"--enable-parallel-tests"
"CC=${lib.getDev mpi}/bin/mpicc"
]);
enableParallelBuilding = true;
disallowedReferences = [ stdenv.cc ];
postFixup = ''
remove-references-to -t ${stdenv.cc} "$(readlink -f $out/lib/libnetcdf.settings)"
'';
doCheck = !mpiSupport;
nativeCheckInputs = [ unzip ];
preCheck = ''
export HOME=$TEMP
'';
meta = {
description = "Libraries for the Unidata network Common Data Format";
platforms = lib.platforms.unix;
homepage = "https://www.unidata.ucar.edu/software/netcdf/";
changelog = "https://docs.unidata.ucar.edu/netcdf-c/${finalAttrs.version}/RELEASE_NOTES.html";
license = lib.licenses.bsd3;
maintainers = with lib.maintainers; [
doronbehar
];
};
})
|