summary refs log tree commit diff
path: root/pkgs/applications/science/biology/mrtrix/default.nix
blob: 6959b2caab8a3e4ddf7ff4d2bc0fe43d95af9489 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
{ stdenv, lib, fetchFromGitHub, python, makeWrapper
, eigen, fftw, libtiff, zlib, ants, bc
, qt5, libGL, libGLU, libX11, libXext
, withGui ? true }:

stdenv.mkDerivation rec {
  pname = "mrtrix";
  version = "3.0_RC3_latest";

  src = fetchFromGitHub {
    owner  = "MRtrix3";
    repo   = "mrtrix3";
    rev    = version;
    sha256 = "184nv524p8j94qicjy9l288bqcgl2yxqqs55a7042i0gfsnwp51c";
    fetchSubmodules = true;
  };

  nativeBuildInputs = [ eigen makeWrapper ] ++ lib.optional withGui qt5.wrapQtAppsHook;

  buildInputs = [
    ants
    python
    fftw
    libtiff
    zlib ] ++ lib.optionals withGui [
    libGL
    libGLU
    libX11
    libXext
    qt5.qtbase
    qt5.qtsvg
  ];

  installCheckInputs = [ bc ];

  postPatch = ''
    patchShebangs ./build ./configure ./run_tests ./bin/population_template
    substituteInPlace ./run_tests  \
      --replace 'git submodule update --init >> $LOGFILE 2>&1' ""
  '';

  configurePhase = ''
    export EIGEN_CFLAGS="-isystem ${eigen}/include/eigen3"
    unset LD  # similar to https://github.com/MRtrix3/mrtrix3/issues/1519
    ./configure ${lib.optionalString (!withGui) "-nogui"};
  '';

  buildPhase = ''
    ./build
    (cd testing && ../build)
  '';

  installCheckPhase = "./run_tests";
  doInstallCheck = true;

  installPhase = ''
    runHook preInstall
    mkdir -p $out
    cp -ar lib $out/lib
    cp -ar bin $out/bin
    runHook postInstall
  '';

  postInstall = ''
    for prog in $out/bin/*; do
      wrapProgram $prog --prefix PATH : ${lib.makeBinPath [ ants ]}
    done
  '';

  meta = with lib; {
    homepage = "https://github.com/MRtrix3/mrtrix3";
    description = "Suite of tools for diffusion imaging";
    maintainers = with maintainers; [ bcdarwin ];
    platforms = platforms.linux;
    license   = licenses.mpl20;
  };
}