2022-06-16 17:23:12 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchurl
|
|
|
|
, fetchFromGitHub
|
2023-03-04 12:14:45 +00:00
|
|
|
, fetchpatch
|
2023-04-29 16:46:19 +00:00
|
|
|
, fetchzip
|
2022-06-16 17:23:12 +00:00
|
|
|
, cmake
|
|
|
|
, lz4
|
2024-05-15 15:35:15 +00:00
|
|
|
, gfortran
|
2022-06-16 17:23:12 +00:00
|
|
|
, bzip2
|
|
|
|
, hdf5
|
|
|
|
, gsl
|
|
|
|
, unzip
|
|
|
|
, makeWrapper
|
2024-05-15 15:35:15 +00:00
|
|
|
, zlib
|
2022-06-16 17:23:12 +00:00
|
|
|
, meson
|
|
|
|
, ninja
|
2024-05-15 15:35:15 +00:00
|
|
|
, pandoc
|
2022-06-16 17:23:12 +00:00
|
|
|
, eigen
|
|
|
|
, pkg-config
|
2024-05-15 15:35:15 +00:00
|
|
|
, wrapGAppsHook3
|
2022-06-16 17:23:12 +00:00
|
|
|
, flex
|
|
|
|
, bison
|
|
|
|
, doxygen
|
|
|
|
, opencl-headers
|
|
|
|
, ncurses
|
|
|
|
, msgpack
|
|
|
|
, fftw
|
|
|
|
, zeromq
|
|
|
|
, ocl-icd
|
|
|
|
, gtk3
|
|
|
|
, gdk-pixbuf
|
|
|
|
, argp-standalone
|
|
|
|
, memorymappingHook
|
|
|
|
, withGui ? true
|
|
|
|
, withBitshuffle ? true
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
libccp4 = stdenv.mkDerivation rec {
|
|
|
|
pname = "libccp4";
|
2023-04-29 16:46:19 +00:00
|
|
|
version = "8.0.0";
|
2022-06-16 17:23:12 +00:00
|
|
|
src = fetchurl {
|
2024-05-15 15:35:15 +00:00
|
|
|
url = "https://ftp.ccp4.ac.uk/opensource/libccp4-${version}.tar.gz";
|
2023-04-29 16:46:19 +00:00
|
|
|
hash = "sha256-y4E66GYSoIZjKd6rfO6W6sVz2BvlskA0HUD5rVMi/y0=";
|
2022-06-16 17:23:12 +00:00
|
|
|
};
|
2023-04-29 16:46:19 +00:00
|
|
|
nativeBuildInputs = [ meson ninja ];
|
2022-06-16 17:23:12 +00:00
|
|
|
buildInputs = [ hdf5 gsl ];
|
|
|
|
|
|
|
|
configureFlags = [ "FFLAGS=-fallow-argument-mismatch" ];
|
|
|
|
|
|
|
|
# libccp4 tries to read syminfo.lib by looking at an environment variable, which hinders reproducibility.
|
|
|
|
# We hard-code this by providing a little patch and then passing the absolute path to syminfo.lib as a
|
|
|
|
# preprocessor flag.
|
2023-04-29 16:46:19 +00:00
|
|
|
env.NIX_CFLAGS_COMPILE = "-DNIX_PROVIDED_SYMOP_FILE=\"${placeholder "out"}/share/ccp4/syminfo.lib\"";
|
2022-06-16 17:23:12 +00:00
|
|
|
|
|
|
|
patches = [
|
|
|
|
./libccp4-use-hardcoded-syminfo-lib.patch
|
|
|
|
];
|
2023-04-29 16:46:19 +00:00
|
|
|
|
|
|
|
postPatch =
|
|
|
|
let
|
|
|
|
mesonPatch = fetchzip {
|
|
|
|
url = "https://wrapdb.mesonbuild.com/v2/libccp4c_8.0.0-1/get_patch#somefile.zip";
|
|
|
|
hash = "sha256-ohskfKh+972Pl56KtwAeWwHtAaAFNpCzz5vZBAI/vdU=";
|
|
|
|
};
|
|
|
|
in
|
|
|
|
''
|
|
|
|
cp ${mesonPatch}/meson.build .
|
|
|
|
'';
|
2022-06-16 17:23:12 +00:00
|
|
|
};
|
|
|
|
# This is the statically-linked, pre-built binary of mosflm. Compiling it ourselves turns out to be very difficult
|
|
|
|
# since the build process is very hard-coded for a specific machine, architecture, and libraries.
|
|
|
|
mosflm =
|
|
|
|
let
|
|
|
|
version = "7.4.0";
|
|
|
|
src =
|
|
|
|
if stdenv.isDarwin then
|
|
|
|
fetchurl
|
|
|
|
{
|
|
|
|
url = "https://www.mrc-lmb.cam.ac.uk/mosflm/mosflm/ver${builtins.replaceStrings [ "." ] [ "" ] version}/pre-built/mosflm-osx-64-noX11.zip";
|
|
|
|
sha256 = "1da5wimv3kl8bccp49j69vh8gi28cn7axg59lrmb38s68c618h7j";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
fetchurl {
|
|
|
|
url = "https://www.mrc-lmb.cam.ac.uk/mosflm/mosflm/ver${builtins.replaceStrings [ "." ] [ "" ] version}/pre-built/mosflm-linux-64-noX11.zip";
|
2023-07-15 17:15:38 +00:00
|
|
|
hash = "sha256:1f2qins5kaz5v6mkaclncqpirx3mlz177ywm13py9p6s9mk99g32";
|
2022-06-16 17:23:12 +00:00
|
|
|
};
|
|
|
|
mosflmBinary = if stdenv.isDarwin then "bin/mosflm" else "mosflm-linux-64-noX11";
|
|
|
|
in
|
2024-05-15 15:35:15 +00:00
|
|
|
stdenv.mkDerivation {
|
2022-06-16 17:23:12 +00:00
|
|
|
pname = "mosflm";
|
|
|
|
|
|
|
|
inherit version src;
|
|
|
|
|
|
|
|
dontBuild = true;
|
|
|
|
|
|
|
|
nativeBuildInputs = [ unzip makeWrapper ];
|
|
|
|
|
|
|
|
sourceRoot = ".";
|
|
|
|
|
|
|
|
# mosflm statically links against its own libccp4, which as the syminfo.lib environment variable problem.
|
|
|
|
# Here, we circumvent it by creating a little wrapper script that calls mosflm after setting the SYMINFO variable.
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/bin
|
|
|
|
cp ${mosflmBinary} $out/bin/mosflm-raw
|
|
|
|
makeWrapper $out/bin/mosflm-raw $out/bin/mosflm --set SYMINFO ${libccp4}/share/syminfo.lib --add-flags -n
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
xgandalf = stdenv.mkDerivation rec {
|
|
|
|
pname = "xgandalf";
|
2023-05-24 13:37:59 +00:00
|
|
|
version = "c6c5003ff1086e8c0fb5313660b4f02f3a3aab7b";
|
2022-06-16 17:23:12 +00:00
|
|
|
src = fetchurl {
|
2024-05-15 15:35:15 +00:00
|
|
|
url = "https://gitlab.desy.de/thomas.white/xgandalf/-/archive/${version}/xgandalf-${version}.tar.gz";
|
2023-05-24 13:37:59 +00:00
|
|
|
hash = "sha256-/uZlBwAINSoYqgLQFTMz8rS1Rpadu79JkO6Bu/+Nx9E=";
|
2022-06-16 17:23:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [ meson pkg-config ninja ];
|
|
|
|
buildInputs = [ eigen ];
|
|
|
|
};
|
|
|
|
|
|
|
|
pinkIndexer = stdenv.mkDerivation rec {
|
|
|
|
pname = "pinkindexer";
|
2024-05-15 15:35:15 +00:00
|
|
|
version = "15caa21191e27e989b750b29566e4379bc5cd21a";
|
2022-06-16 17:23:12 +00:00
|
|
|
src = fetchurl {
|
|
|
|
url = "https://gitlab.desy.de/thomas.white/${pname}/-/archive/${version}/${pname}-${version}.tar.gz";
|
2024-05-15 15:35:15 +00:00
|
|
|
hash = "sha256-v/SCJiHAV05Lc905y/dE8uBXlW+lLX9wau4XORYdbQg=";
|
2022-06-16 17:23:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [ meson pkg-config ninja ];
|
|
|
|
buildInputs = [ eigen ];
|
|
|
|
};
|
|
|
|
|
|
|
|
fdip = stdenv.mkDerivation rec {
|
|
|
|
pname = "fdip";
|
2023-05-24 13:37:59 +00:00
|
|
|
version = "5628fedddd79323b4b26df9b85e9543d83286d4c";
|
2022-06-16 17:23:12 +00:00
|
|
|
src = fetchurl {
|
2023-05-24 13:37:59 +00:00
|
|
|
url = "https://gitlab.desy.de/thomas.white/fdip/-/archive/${version}/fdip-${version}.tar.gz";
|
|
|
|
hash = "sha256-EaihnW7p//ecgMn+KKlfmBeXrnAqs+HdhN+ovuSrtiQ=";
|
2022-06-16 17:23:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [ meson ninja pkg-config ];
|
|
|
|
buildInputs = [ eigen ];
|
|
|
|
};
|
|
|
|
|
|
|
|
hdf5-external-filter-plugins = stdenv.mkDerivation rec {
|
|
|
|
pname = "HDF5-External-Filter-Plugins";
|
|
|
|
version = "0.1.0";
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "nexusformat";
|
|
|
|
repo = pname;
|
2023-04-29 16:46:19 +00:00
|
|
|
rev = "49e3b65eca772bca77af13ba047d8b577673afba";
|
|
|
|
hash = "sha256-bEzfWdZuHmb0PDzCqy8Dey4tLtq+4coO0sT0GzqrTYI=";
|
2022-06-16 17:23:12 +00:00
|
|
|
};
|
|
|
|
|
2023-04-29 16:46:19 +00:00
|
|
|
patches = [
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://github.com/spanezz/HDF5-External-Filter-Plugins/commit/6b337fe36da97a3ef72354393687ce3386c0709d.patch";
|
|
|
|
hash = "sha256-wnBEdL/MjEyRHPwaVtuhzY+DW1AFeaUQUmIXh+JaRHo=";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2022-06-16 17:23:12 +00:00
|
|
|
nativeBuildInputs = [ cmake ];
|
|
|
|
buildInputs = [ hdf5 lz4 bzip2 ];
|
|
|
|
|
|
|
|
cmakeFlags = [
|
|
|
|
"-DENABLE_BITSHUFFLE_PLUGIN=yes"
|
|
|
|
"-DENABLE_LZ4_PLUGIN=yes"
|
|
|
|
"-DENABLE_BZIP2_PLUGIN=yes"
|
|
|
|
];
|
|
|
|
};
|
2024-05-15 15:35:15 +00:00
|
|
|
|
|
|
|
millepede-ii = stdenv.mkDerivation rec {
|
|
|
|
pname = "millepede-ii";
|
|
|
|
version = "04-13-06";
|
|
|
|
src = fetchurl {
|
|
|
|
url = "https://gitlab.desy.de/claus.kleinwort/millepede-ii/-/archive/V${version}/millepede-ii-V${version}.tar.gz";
|
|
|
|
hash = "sha256-aFoo8AGBsUEN2u3AmnSpTqJ6JeNV6j9vkAFTZ34I+sI=";
|
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [ gfortran ];
|
|
|
|
buildInputs = [ zlib ];
|
|
|
|
|
|
|
|
makeFlags = [ "PREFIX=$(out)" ];
|
|
|
|
};
|
2022-06-16 17:23:12 +00:00
|
|
|
in
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "crystfel";
|
2024-05-15 15:35:15 +00:00
|
|
|
version = "0.11.0";
|
2022-06-16 17:23:12 +00:00
|
|
|
src = fetchurl {
|
2024-05-15 15:35:15 +00:00
|
|
|
url = "https://www.desy.de/~twhite/crystfel/crystfel-${version}.tar.gz";
|
|
|
|
sha256 = "sha256-ogNHWYfbxRmB5TdK8K0JpcCnYOOyXapQGSPh8mfp+Tc=";
|
2022-06-16 17:23:12 +00:00
|
|
|
};
|
2022-10-06 18:32:54 +00:00
|
|
|
nativeBuildInputs = [ meson pkg-config ninja flex bison doxygen opencl-headers makeWrapper ]
|
2024-05-15 15:35:15 +00:00
|
|
|
++ lib.optionals withGui [ wrapGAppsHook3 ];
|
2022-06-16 17:23:12 +00:00
|
|
|
buildInputs = [
|
|
|
|
hdf5
|
|
|
|
gsl
|
|
|
|
ncurses
|
|
|
|
msgpack
|
|
|
|
fftw
|
|
|
|
fdip
|
|
|
|
zeromq
|
|
|
|
ocl-icd
|
|
|
|
libccp4
|
|
|
|
mosflm
|
|
|
|
pinkIndexer
|
|
|
|
xgandalf
|
2024-05-15 15:35:15 +00:00
|
|
|
pandoc
|
2022-06-16 17:23:12 +00:00
|
|
|
] ++ lib.optionals withGui [ gtk3 gdk-pixbuf ]
|
|
|
|
++ lib.optionals stdenv.isDarwin [
|
|
|
|
argp-standalone
|
2023-04-29 16:46:19 +00:00
|
|
|
] ++ lib.optionals (stdenv.isDarwin && !stdenv.isAarch64) [
|
2022-06-16 17:23:12 +00:00
|
|
|
memorymappingHook
|
|
|
|
]
|
2023-04-29 16:46:19 +00:00
|
|
|
++ lib.optionals withBitshuffle [ hdf5-external-filter-plugins ];
|
2022-06-16 17:23:12 +00:00
|
|
|
|
2023-03-04 12:14:45 +00:00
|
|
|
patches = [
|
2024-05-15 15:35:15 +00:00
|
|
|
# on darwin at least, we need to link to a separate argp library;
|
|
|
|
# this patch adds a test for this and the necessary linker options
|
2023-03-04 12:14:45 +00:00
|
|
|
./link-to-argp-standalone-if-needed.patch
|
2024-05-15 15:35:15 +00:00
|
|
|
# hotfix for an issue that occurs (at least) on NixOS:
|
|
|
|
# if the temporary path is too long, we get a segfault
|
|
|
|
./gui-path-issue.patch
|
2023-03-04 12:14:45 +00:00
|
|
|
];
|
2022-06-16 17:23:12 +00:00
|
|
|
|
|
|
|
# CrystFEL calls mosflm by searching PATH for it. We could've create a wrapper script that sets the PATH, but
|
|
|
|
# we'd have to do that for every CrystFEL executable (indexamajig, crystfel, partialator). Better to just
|
|
|
|
# hard-code mosflm's path once.
|
|
|
|
postPatch = ''
|
|
|
|
sed -i -e 's#execlp("mosflm"#execl("${mosflm}/bin/mosflm"#' libcrystfel/src/indexers/mosflm.c;
|
|
|
|
'';
|
|
|
|
|
2023-04-29 16:46:19 +00:00
|
|
|
postInstall = lib.optionalString withBitshuffle ''
|
2022-06-16 17:23:12 +00:00
|
|
|
for file in $out/bin/*; do
|
2024-05-15 15:35:15 +00:00
|
|
|
wrapProgram $file \
|
|
|
|
--set HDF5_PLUGIN_PATH ${hdf5-external-filter-plugins}/lib/plugins \
|
|
|
|
--prefix PATH ":" ${lib.makeBinPath [ millepede-ii ]}
|
2022-06-16 17:23:12 +00:00
|
|
|
done
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "Data processing for serial crystallography";
|
|
|
|
longDescription = ''
|
|
|
|
CrystFEL is a suite of programs for processing (and simulating) Bragg diffraction data from "serial crystallography" experiments, often (but not always) performed using an X-ray Free-Electron Laser. Compared to rotation data, some of the particular characteristics of such data which call for a specialised software suite are:
|
|
|
|
|
|
|
|
- The sliced, rather than integrated, measurement of intensity data. Many, if not all reflections are partially integrated.
|
|
|
|
- Many patterns (thousands) are required - high throughput is needed.
|
|
|
|
- The crystal orientations in each pattern are random and uncorrelated.
|
|
|
|
- Merging into lower symmetry point groups may require the resolution of indexing ambiguities.'';
|
|
|
|
homepage = "https://www.desy.de/~twhite/crystfel/";
|
|
|
|
changelog = "https://www.desy.de/~twhite/crystfel/changes.html";
|
|
|
|
downloadPage = "https://www.desy.de/~twhite/crystfel/download.html";
|
|
|
|
license = licenses.gpl3Plus;
|
|
|
|
maintainers = with maintainers; [ pmiddend ];
|
2023-04-29 16:46:19 +00:00
|
|
|
platforms = platforms.unix;
|
2022-06-16 17:23:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|