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