Merge pull request #218968 from pmiddend/crystfel-aarch64

CrystFEL: support aarch64-linux and HDF5 on Darwin

authored by Weijia Wang and committed by GitHub 7b57f591 059148a9

+44 -62
-43
pkgs/applications/science/physics/crystfel/0002-fix-ftbfs-with-gcc-10.patch
··· 1 - Description: Fixing argument mismatches in Fortran code, addressing #957430. 2 - Author: Andrius Merkys <merkys@debian.org> 3 - Forwarded: ccp4-dev@dl.ac.uk 4 - --- a/fortran/pack_f.f 5 - +++ b/fortran/pack_f.f 6 - @@ -106,7 +106,7 @@ 7 - endif 8 - 10 continue 9 - filnarray(len(filn) + 1) = 0 10 - - call pack_wordimage_f(data, x, y, filnarray) 11 - + call pack_longimage_f(data, x, y, filnarray) 12 - return 13 - end 14 - 15 - @@ -138,7 +138,7 @@ 16 - endif 17 - 10 continue 18 - filnarray(len(filn) + 1) = 0 19 - - call v2pack_wordimage_f(data, x, y, filnarray) 20 - + call v2pack_longimage_f(data, x, y, filnarray) 21 - return 22 - end 23 - 24 - --- a/fortran/lgglib.f 25 - +++ b/fortran/lgglib.f 26 - @@ -1236,7 +1236,7 @@ 27 - B3(2) = XYZ(2) * CELL(2) 28 - B3(3) = XYZ(3) * CELL(3) 29 - C 30 - - CALL matmult(3,3,3,1,ORTH,B3,XYZ,B1) 31 - + CALL matmult(3,3,3,1,ORTH,B3,XYZ) 32 - END 33 - c 34 - c 35 - @@ -1274,7 +1274,7 @@ 36 - B3(1) = XYZ(1) 37 - B3(2) = XYZ(2) 38 - B3(3) = XYZ(3) 39 - - CALL matmult(3,3,3,1,ORTH,B3,XYZ,B1) 40 - + CALL matmult(3,3,3,1,ORTH,B3,XYZ) 41 - END 42 - character*80 function getnam(filnam) 43 - character*(*) filnam
···
+31 -19
pkgs/applications/science/physics/crystfel/default.nix
··· 3 , fetchurl 4 , fetchFromGitHub 5 , fetchpatch 6 , cmake 7 , lz4 8 , bzip2 9 - , gfortran 10 , m4 11 , hdf5 12 , gsl ··· 38 let 39 libccp4 = stdenv.mkDerivation rec { 40 pname = "libccp4"; 41 - version = "6.5.1"; 42 src = fetchurl { 43 - # Original mirror, now times out 44 - # url = "ftp://ftp.ccp4.ac.uk/opensource/${pname}-${version}.tar.gz"; 45 - url = "https://deb.debian.org/debian/pool/main/libc/${pname}/${pname}_${version}.orig.tar.gz"; 46 - sha256 = "1rfvjliny29vy5bdi6rrjaw9hhhhh72pw536xwvqipqcjlylf2r8"; 47 }; 48 - nativeBuildInputs = [ gfortran m4 ]; 49 buildInputs = [ hdf5 gsl ]; 50 51 configureFlags = [ "FFLAGS=-fallow-argument-mismatch" ]; ··· 53 # libccp4 tries to read syminfo.lib by looking at an environment variable, which hinders reproducibility. 54 # We hard-code this by providing a little patch and then passing the absolute path to syminfo.lib as a 55 # preprocessor flag. 56 - preBuild = '' 57 - makeFlagsArray+=(CFLAGS='-DNIX_PROVIDED_SYMOP_FILE=\"${placeholder "out"}/share/syminfo.lib\"') 58 - export NIX_LDFLAGS="-L${gfortran.cc}/lib64 -L${gfortran.cc}/lib $NIX_LDFLAGS"; 59 - ''; 60 - makeFlags = [ "CFLAGS='-DNIX_PROVIDED_SYMOP_FILE=\"${placeholder "out"}/share/syminfo.lib\"" ]; 61 62 patches = [ 63 ./libccp4-use-hardcoded-syminfo-lib.patch 64 - ./0002-fix-ftbfs-with-gcc-10.patch 65 ]; 66 }; 67 # This is the statically-linked, pre-built binary of mosflm. Compiling it ourselves turns out to be very difficult 68 # since the build process is very hard-coded for a specific machine, architecture, and libraries. ··· 145 src = fetchFromGitHub { 146 owner = "nexusformat"; 147 repo = pname; 148 - rev = "d469f175e5273c1d488e71a6134f84088f57d39c"; 149 - sha256 = "1jrzzh75i68ad1yrim7s1nx9wy0s49ghkziahs71mm5azprm6gh9"; 150 }; 151 152 nativeBuildInputs = [ cmake ]; 153 buildInputs = [ hdf5 lz4 bzip2 ]; 154 ··· 184 ] ++ lib.optionals withGui [ gtk3 gdk-pixbuf ] 185 ++ lib.optionals stdenv.isDarwin [ 186 argp-standalone 187 memorymappingHook 188 ] 189 - # hdf5-external-filter-plugins doesn't link on Darwin 190 - ++ lib.optionals (withBitshuffle && !stdenv.isDarwin) [ hdf5-external-filter-plugins ]; 191 192 patches = [ 193 ./link-to-argp-standalone-if-needed.patch 194 (fetchpatch { 195 url = "https://gitlab.desy.de/thomas.white/crystfel/-/commit/3c54d59e1c13aaae716845fed2585770c3ca9d14.diff"; 196 hash = "sha256-oaJNBQQn0c+z4p1pnW4osRJA2KdKiz4hWu7uzoKY7wc="; ··· 204 sed -i -e 's#execlp("mosflm"#execl("${mosflm}/bin/mosflm"#' libcrystfel/src/indexers/mosflm.c; 205 ''; 206 207 - postInstall = lib.optionalString (withBitshuffle && !stdenv.isDarwin) '' 208 for file in $out/bin/*; do 209 wrapProgram $file --set HDF5_PLUGIN_PATH ${hdf5-external-filter-plugins}/lib/plugins 210 done ··· 224 downloadPage = "https://www.desy.de/~twhite/crystfel/download.html"; 225 license = licenses.gpl3Plus; 226 maintainers = with maintainers; [ pmiddend ]; 227 - platforms = [ "x86_64-linux" "x86_64-darwin" ]; 228 }; 229 230 }
··· 3 , fetchurl 4 , fetchFromGitHub 5 , fetchpatch 6 + , fetchzip 7 , cmake 8 , lz4 9 , bzip2 10 , m4 11 , hdf5 12 , gsl ··· 38 let 39 libccp4 = stdenv.mkDerivation rec { 40 pname = "libccp4"; 41 + version = "8.0.0"; 42 src = fetchurl { 43 + url = "https://ftp.ccp4.ac.uk/opensource/${pname}-${version}.tar.gz"; 44 + hash = "sha256-y4E66GYSoIZjKd6rfO6W6sVz2BvlskA0HUD5rVMi/y0="; 45 }; 46 + nativeBuildInputs = [ meson ninja ]; 47 buildInputs = [ hdf5 gsl ]; 48 49 configureFlags = [ "FFLAGS=-fallow-argument-mismatch" ]; ··· 51 # libccp4 tries to read syminfo.lib by looking at an environment variable, which hinders reproducibility. 52 # We hard-code this by providing a little patch and then passing the absolute path to syminfo.lib as a 53 # preprocessor flag. 54 + env.NIX_CFLAGS_COMPILE = "-DNIX_PROVIDED_SYMOP_FILE=\"${placeholder "out"}/share/ccp4/syminfo.lib\""; 55 56 patches = [ 57 ./libccp4-use-hardcoded-syminfo-lib.patch 58 ]; 59 + 60 + postPatch = 61 + let 62 + mesonPatch = fetchzip { 63 + url = "https://wrapdb.mesonbuild.com/v2/libccp4c_8.0.0-1/get_patch#somefile.zip"; 64 + hash = "sha256-ohskfKh+972Pl56KtwAeWwHtAaAFNpCzz5vZBAI/vdU="; 65 + }; 66 + in 67 + '' 68 + cp ${mesonPatch}/meson.build . 69 + ''; 70 }; 71 # This is the statically-linked, pre-built binary of mosflm. Compiling it ourselves turns out to be very difficult 72 # since the build process is very hard-coded for a specific machine, architecture, and libraries. ··· 149 src = fetchFromGitHub { 150 owner = "nexusformat"; 151 repo = pname; 152 + rev = "49e3b65eca772bca77af13ba047d8b577673afba"; 153 + hash = "sha256-bEzfWdZuHmb0PDzCqy8Dey4tLtq+4coO0sT0GzqrTYI="; 154 }; 155 156 + patches = [ 157 + (fetchpatch { 158 + url = "https://github.com/spanezz/HDF5-External-Filter-Plugins/commit/6b337fe36da97a3ef72354393687ce3386c0709d.patch"; 159 + hash = "sha256-wnBEdL/MjEyRHPwaVtuhzY+DW1AFeaUQUmIXh+JaRHo="; 160 + }) 161 + ]; 162 + 163 nativeBuildInputs = [ cmake ]; 164 buildInputs = [ hdf5 lz4 bzip2 ]; 165 ··· 195 ] ++ lib.optionals withGui [ gtk3 gdk-pixbuf ] 196 ++ lib.optionals stdenv.isDarwin [ 197 argp-standalone 198 + ] ++ lib.optionals (stdenv.isDarwin && !stdenv.isAarch64) [ 199 memorymappingHook 200 ] 201 + ++ lib.optionals withBitshuffle [ hdf5-external-filter-plugins ]; 202 203 patches = [ 204 ./link-to-argp-standalone-if-needed.patch 205 + ./disable-fmemopen-on-aarch64-darwin.patch 206 (fetchpatch { 207 url = "https://gitlab.desy.de/thomas.white/crystfel/-/commit/3c54d59e1c13aaae716845fed2585770c3ca9d14.diff"; 208 hash = "sha256-oaJNBQQn0c+z4p1pnW4osRJA2KdKiz4hWu7uzoKY7wc="; ··· 216 sed -i -e 's#execlp("mosflm"#execl("${mosflm}/bin/mosflm"#' libcrystfel/src/indexers/mosflm.c; 217 ''; 218 219 + postInstall = lib.optionalString withBitshuffle '' 220 for file in $out/bin/*; do 221 wrapProgram $file --set HDF5_PLUGIN_PATH ${hdf5-external-filter-plugins}/lib/plugins 222 done ··· 236 downloadPage = "https://www.desy.de/~twhite/crystfel/download.html"; 237 license = licenses.gpl3Plus; 238 maintainers = with maintainers; [ pmiddend ]; 239 + platforms = platforms.unix; 240 }; 241 242 }
+13
pkgs/applications/science/physics/crystfel/disable-fmemopen-on-aarch64-darwin.patch
···
··· 1 + diff --git a/libcrystfel/src/image-cbf.c b/libcrystfel/src/image-cbf.c 2 + index b8f09a1f..f8a15c1b 100644 3 + --- a/libcrystfel/src/image-cbf.c 4 + +++ b/libcrystfel/src/image-cbf.c 5 + @@ -287,7 +287,7 @@ static float *read_cbf_data(const char *filename, int gz, int *w, int *h) 6 + 7 + } else { 8 + 9 + - #ifdef HAVE_ZLIB 10 + + #if defined(HAVE_ZLIB) && !(defined(__aarch64__) && defined(__APPLE__)) 11 + gzFile gzfh; 12 + int len_read; 13 + size_t len;