nixpkgs/pkgs/by-name/ne/netcdf/package.nix
aleksana 571c71e6f7 treewide: migrate packages to pkgs/by-name, take 1
We are migrating packages that meet below requirements:

1. using `callPackage`
2. called path is a directory
3. overriding set is empty (`{ }`)
4. not containing path expressions other than relative path (to
makenixpkgs-vet happy)
5. not referenced by nix files outside of the directory, other
than`pkgs/top-level/all-packages.nix`
6. not referencing nix files outside of the directory
7. not referencing `default.nix` (since it's changed to `package.nix`)
8. `outPath` doesn't change after migration

The tool is here: https://github.com/Aleksanaa/by-name-migrate.
2024-11-09 20:04:51 +08:00

92 lines
2.2 KiB
Nix

{ lib, stdenv
, fetchurl, unzip
, hdf5
, bzip2
, libzip
, zstd
, szipSupport ? false
, szip
, libxml2
, m4
, curl # for DAP
, removeReferencesTo
}:
let
inherit (hdf5) mpiSupport mpi;
in stdenv.mkDerivation rec {
pname = "netcdf" + lib.optionalString mpiSupport "-mpi";
version = "4.9.2";
src = fetchurl {
url = "https://downloads.unidata.ucar.edu/netcdf-c/${version}/netcdf-c-${version}.tar.gz";
hash = "sha256-zxG6u725lj8J9VB54LAZ9tA3H1L44SZKW6jp/asabEg=";
};
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 ];
buildInputs = [
curl
hdf5
libxml2
mpi
bzip2
libzip
zstd
] ++ lib.optional szipSupport szip;
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/${version}/RELEASE_NOTES.html";
license = lib.licenses.bsd3;
};
}