@@ -0,0 +1,78 @@
1+{ stdenv
2+, fetchzip
3+, fetchFromGitHub
4+, cmake
5+, fftw
6+, fftwFloat
7+, enablePython ? false
8+, pythonPackages
9+, llvmPackages
10+}:
11+let
12+ # CMake recipes are needed to build galario
13+ # Build process would usually download them
14+ great-cmake-cookoff = fetchzip {
15+ url = "https://github.com/UCL/GreatCMakeCookOff/archive/v2.1.9.tar.gz";
16+ sha256 = "1yd53b5gx38g6f44jmjk4lc4igs3p25z6616hfb7aq79ly01q0w2";
17+ };
18+in
19+stdenv.mkDerivation rec {
20+ pname = "galario";
21+ version = "1.2.1";
22+
23+ src = fetchFromGitHub {
24+ owner = "mtazzari";
25+ repo = pname;
26+ rev = "v${version}";
27+ sha256 = "1akz7md7ly16a89zr880c265habakqdg9sj8iil90klqa0i21w6g";
28+ };
29+
30+ nativeBuildInputs = [ cmake ];
31+
32+ buildInputs = [ fftw fftwFloat ]
33+ ++ stdenv.lib.optional enablePython pythonPackages.python
34+ ++ stdenv.lib.optional stdenv.isDarwin llvmPackages.openmp
35+ ;
36+
37+ propagatedBuildInputs = stdenv.lib.optional enablePython [
38+ pythonPackages.numpy
39+ pythonPackages.cython
40+ pythonPackages.pytest
41+ ];
42+
43+ checkInputs = stdenv.lib.optional enablePython pythonPackages.scipy;
44+
45+ preConfigure = ''
46+ mkdir -p build/external/src
47+ cp -r ${great-cmake-cookoff} build/external/src/GreatCMakeCookOff
48+ chmod -R 777 build/external/src/GreatCMakeCookOff
49+ '';
50+
51+ preCheck = ''
52+ ${if stdenv.isDarwin then "export DYLD_LIBRARY_PATH=$(pwd)/src/" else "export LD_LIBRARY_PATH=$(pwd)/src/"}
53+ ${if enablePython then "sed -i -e 's|^#!.*|#!${stdenv.shell}|' python/py.test.sh" else ""}
54+ '';
55+
56+ doCheck = true;
57+
58+ postInstall = stdenv.lib.optionalString (stdenv.isDarwin && enablePython) ''
59+ install_name_tool -change libgalario.dylib $out/lib/libgalario.dylib $out/lib/python*/site-packages/galario/double/libcommon.so
60+ install_name_tool -change libgalario_single.dylib $out/lib/libgalario_single.dylib $out/lib/python*/site-packages/galario/single/libcommon.so
61+ '';
62+
63+ meta = with stdenv.lib; {
64+ description = "GPU Accelerated Library for Analysing Radio Interferometer Observations";
65+ longDescription = ''
66+ Galario is a library that exploits the computing power of modern
67+ graphic cards (GPUs) to accelerate the comparison of model
68+ predictions to radio interferometer observations. Namely, it
69+ speeds up the computation of the synthetic visibilities given a
70+ model image (or an axisymmetric brightness profile) and their
71+ comparison to the observations.
72+ '';
73+ homepage = "https://mtazzari.github.io/galario/";
74+ license = licenses.lgpl3;
75+ maintainers = [ maintainers.smaret ];
76+ platforms = platforms.all;
77+ };
78+}