2020-04-24 23:36:52 +00:00
|
|
|
{ stdenv, lib, fetchFromGitHub, python, makeWrapper
|
2020-05-15 21:57:56 +00:00
|
|
|
, eigen, fftw, libtiff, libpng, zlib, ants, bc
|
2020-04-24 23:36:52 +00:00
|
|
|
, qt5, libGL, libGLU, libX11, libXext
|
2021-12-06 16:07:01 +00:00
|
|
|
, withGui ? true, less }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "mrtrix";
|
2021-12-06 16:07:01 +00:00
|
|
|
version = "unstable-2021-11-25";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "MRtrix3";
|
|
|
|
repo = "mrtrix3";
|
2021-12-06 16:07:01 +00:00
|
|
|
rev = "994498557037c9e4f7ba67f255820ef84ea899d9";
|
|
|
|
sha256 = "sha256-8eFDS5z4ZxMzi9Khk90KAS4ndma/Syd6JDXM2Fpr0M8=";
|
2020-04-24 23:36:52 +00:00
|
|
|
fetchSubmodules = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [ eigen makeWrapper ] ++ lib.optional withGui qt5.wrapQtAppsHook;
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
ants
|
|
|
|
python
|
|
|
|
fftw
|
|
|
|
libtiff
|
2020-05-15 21:57:56 +00:00
|
|
|
libpng
|
|
|
|
zlib
|
|
|
|
] ++ lib.optionals withGui [
|
2020-04-24 23:36:52 +00:00
|
|
|
libGL
|
|
|
|
libGLU
|
|
|
|
libX11
|
|
|
|
libXext
|
|
|
|
qt5.qtbase
|
|
|
|
qt5.qtsvg
|
|
|
|
];
|
|
|
|
|
|
|
|
installCheckInputs = [ bc ];
|
|
|
|
|
|
|
|
postPatch = ''
|
2020-05-15 21:57:56 +00:00
|
|
|
patchShebangs ./build ./configure ./run_tests ./bin/*
|
|
|
|
|
|
|
|
# patching interpreters before fixup is needed for tests:
|
|
|
|
patchShebangs ./bin/*
|
|
|
|
patchShebangs testing/binaries/data/vectorstats/*py
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
substituteInPlace ./run_tests \
|
2020-05-15 21:57:56 +00:00
|
|
|
--replace 'git submodule update --init $datadir >> $LOGFILE 2>&1' ""
|
2021-12-06 16:07:01 +00:00
|
|
|
|
|
|
|
substituteInPlace ./build \
|
|
|
|
--replace '"less -RX "' '"${less}/bin/less -RX "'
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
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)
|
|
|
|
'';
|
|
|
|
|
2020-05-15 21:57:56 +00:00
|
|
|
installCheckPhase = ''
|
|
|
|
./run_tests units
|
|
|
|
./run_tests binaries
|
|
|
|
|
|
|
|
# can also `./run_tests scripts`, but this fails due to lack of FSL package
|
|
|
|
# (and there's no convenient way to disable individual tests)
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
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
|
2020-05-15 21:57:56 +00:00
|
|
|
if [[ -x "$prog" ]]; then
|
|
|
|
wrapProgram $prog --prefix PATH : ${lib.makeBinPath [ ants ]}
|
|
|
|
fi
|
2020-04-24 23:36:52 +00:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
}
|