7 , fortranSupport ? false
15 , enableShared ? !stdenv.hostPlatform.isStatic
16 , enableStatic ? stdenv.hostPlatform.isStatic
24 # cpp and mpi options are mutually exclusive
25 # (--enable-unsupported could be used to force the build)
26 assert !cppSupport || !mpiSupport;
28 let inherit (lib) optional optionals; in
30 stdenv.mkDerivation rec {
33 + lib.optionalString cppSupport "-cpp"
34 + lib.optionalString fortranSupport "-fortran"
35 + lib.optionalString mpiSupport "-mpi"
36 + lib.optionalString threadsafe "-threadsafe";
38 src = fetchFromGitHub {
41 rev = "hdf5_${version}";
42 hash = "sha256-lvz3x04SS0oZmUn/BIxQEHnugaDOws46kfT3NAw7Hos=";
59 outputs = [ "out" "dev" "bin" ];
61 nativeBuildInputs = [ removeReferencesTo cmake ]
62 ++ optional fortranSupport fortran;
64 buildInputs = optional fortranSupport fortran
65 ++ optional szipSupport szip
66 ++ optional javaSupport jdk;
68 propagatedBuildInputs = optional zlibSupport zlib
69 ++ optional mpiSupport mpi;
72 "-DHDF5_INSTALL_CMAKE_DIR=${placeholder "dev"}/lib/cmake"
73 "-DBUILD_STATIC_LIBS=${lib.boolToString enableStatic}"
74 ] ++ lib.optional stdenv.hostPlatform.isDarwin "-DHDF5_BUILD_WITH_INSTALL_NAME=ON"
75 ++ lib.optional cppSupport "-DHDF5_BUILD_CPP_LIB=ON"
76 ++ lib.optional fortranSupport "-DHDF5_BUILD_FORTRAN=ON"
77 ++ lib.optional szipSupport "-DHDF5_ENABLE_SZIP_SUPPORT=ON"
78 ++ lib.optionals mpiSupport [ "-DHDF5_ENABLE_PARALLEL=ON" ]
79 ++ lib.optional enableShared "-DBUILD_SHARED_LIBS=ON"
80 ++ lib.optional javaSupport "-DHDF5_BUILD_JAVA=ON"
81 ++ lib.optional usev110Api "-DDEFAULT_API_VERSION=v110"
82 ++ lib.optionals threadsafe [ "-DDHDF5_ENABLE_THREADSAFE:BOOL=ON" "-DHDF5_BUILD_HL_LIB=OFF" ]
83 # broken in nixpkgs since around 1.14.3 -> 1.14.4.3
84 # https://github.com/HDFGroup/hdf5/issues/4208#issuecomment-2098698567
85 ++ lib.optional (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) "-DHDF5_ENABLE_NONSTANDARD_FEATURE_FLOAT16=OFF"
89 find "$out" -type f -exec remove-references-to -t ${stdenv.cc} '{}' +
90 moveToOutput 'bin/' "''${!outputBin}"
91 moveToOutput 'bin/h5cc' "''${!outputDev}"
92 moveToOutput 'bin/h5c++' "''${!outputDev}"
93 moveToOutput 'bin/h5fc' "''${!outputDev}"
94 moveToOutput 'bin/h5pcc' "''${!outputDev}"
95 moveToOutput 'bin/h5hlcc' "''${!outputDev}"
96 moveToOutput 'bin/h5hlc++' "''${!outputDev}"
97 '' + lib.optionalString enableShared
98 # The shared build creates binaries with -shared suffixes,
99 # so we remove these suffixes.
101 pushd ''${!outputBin}/bin
102 for file in *-shared; do
103 mv "$file" "''${file%%-shared}"
106 '' + lib.optionalString fortranSupport
108 mv $out/mod/shared $dev/include
111 find "$out" -type f -exec remove-references-to -t ${fortran} '{}' +
114 enableParallelBuilding = true;
117 inherit (python3.pkgs) h5py;
121 description = "Data model, library, and file format for storing and managing data";
123 HDF5 supports an unlimited variety of datatypes, and is designed for flexible and efficient
124 I/O and for high volume and complex data. HDF5 is portable and is extensible, allowing
125 applications to evolve in their use of HDF5. The HDF5 Technology suite includes tools and
126 applications for managing, manipulating, viewing, and analyzing data in the HDF5 format.
128 license = licenses.bsd3; # Lawrence Berkeley National Labs BSD 3-Clause variant
129 maintainers = [ maintainers.markuskowa ];
130 homepage = "https://www.hdfgroup.org/HDF5/";
131 platforms = platforms.unix;