From 9a2cd20478850a577d0b85166e7c071a250ed193 Mon Sep 17 00:00:00 2001 From: Ben Darwin Date: Sun, 16 Feb 2020 14:45:22 -0500 Subject: [PATCH] mrtrix: init at 3.0_RC3_latest This package consists mostly of command-line tools, but there are also two qt5-based image viewers (`mrview` and `shview`). I have provided an option `withGui = true` to allow users to disable these viewers. They work on NixOS but unlikely to work out-of-the box on non-NixOS Linux (see #62169), but I've refrained from asserting that they shouldn't be built since a user might want to fiddle with runtime GL stuff. Some programs rely on FSL and/or ANTs backends; I have somewhat heavy-handedly wrapped all binaries to point to ANTs, while FSL is not available in Nix at the moment and has a non-commercial license so would be convenient to disable by default for Hydra builds. --- .../science/biology/mrtrix/default.nix | 77 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 + 2 files changed, 79 insertions(+) create mode 100644 pkgs/applications/science/biology/mrtrix/default.nix diff --git a/pkgs/applications/science/biology/mrtrix/default.nix b/pkgs/applications/science/biology/mrtrix/default.nix new file mode 100644 index 00000000000..6959b2caab8 --- /dev/null +++ b/pkgs/applications/science/biology/mrtrix/default.nix @@ -0,0 +1,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; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 5d3691ce229..52b77558b45 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -23907,6 +23907,8 @@ in mrbayes = callPackage ../applications/science/biology/mrbayes { }; + mrtrix = callPackage ../applications/science/biology/mrtrix { python = python3; }; + megahit = callPackage ../applications/science/biology/megahit { }; messer-slim = callPackage ../applications/science/biology/messer-slim { };