diff options
author | Sandro <sandro.jaeckel@gmail.com> | 2022-04-25 11:59:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-25 11:59:49 +0200 |
commit | 2f517412c45e9b2e552b499a7290d0adfcaf8801 (patch) | |
tree | 7e7584c819b45426af6f04b083082d077d1c9f70 /pkgs/applications/science | |
parent | 7c4d42ca7720da83c3d1484c5f1b8fff29032b35 (diff) | |
parent | d1c3fea7ecbed758168787fe4e4a3157e52bc808 (diff) |
Merge pull request #165477 from rbreslow/dcm2niix-optional-modules
Diffstat (limited to 'pkgs/applications/science')
-rw-r--r-- | pkgs/applications/science/biology/dcm2niix/default.nix | 49 | ||||
-rw-r--r-- | pkgs/applications/science/biology/dcm2niix/dont-fetch-external-libs.patch | 36 |
2 files changed, 78 insertions, 7 deletions
diff --git a/pkgs/applications/science/biology/dcm2niix/default.nix b/pkgs/applications/science/biology/dcm2niix/default.nix index 36dddad5db5ac..90eef027a8425 100644 --- a/pkgs/applications/science/biology/dcm2niix/default.nix +++ b/pkgs/applications/science/biology/dcm2niix/default.nix @@ -1,10 +1,26 @@ -{ lib, stdenv +{ lib +, stdenv , fetchFromGitHub +, substituteAll , cmake +, openjpeg , libyamlcpp -, git +, batchVersion ? false +, withJpegLs ? true +, withOpenJpeg ? true +, withCloudflareZlib ? true }: +let + cloudflareZlib = fetchFromGitHub { + owner = "ningfei"; + repo = "zlib"; + # HEAD revision of the gcc.amd64 branch on 2022-04-14. Reminder to update + # whenever bumping package version. + rev = "fda61188d1d4dcd21545c34c2a2f5cc9b0f5db4b"; + sha256 = "sha256-qySFwY0VI2BQLO2XoCZeYshXEDnHh6SmJ3MvcBUROWU="; + }; +in stdenv.mkDerivation rec { version = "1.0.20211006"; pname = "dcm2niix"; @@ -16,18 +32,37 @@ stdenv.mkDerivation rec { sha256 = "sha256-fQAVOzynMdSLDfhcYWcaXkFW/mnv4zySGLVJNE7ql/c="; }; - nativeBuildInputs = [ cmake git ]; - buildInputs = [ libyamlcpp ]; + patches = lib.optionals withCloudflareZlib [ + (substituteAll { + src = ./dont-fetch-external-libs.patch; + inherit cloudflareZlib; + }) + ]; + + nativeBuildInputs = [ cmake ]; + buildInputs = lib.optionals batchVersion [ libyamlcpp ] + ++ lib.optionals withOpenJpeg [ openjpeg openjpeg.dev ]; + + cmakeFlags = lib.optionals batchVersion [ + "-DBATCH_VERSION=ON" + "-DYAML-CPP_DIR=${libyamlcpp}/lib/cmake/yaml-cpp" + ] ++ lib.optionals withJpegLs [ + "-DUSE_JPEGLS=ON" + ] ++ lib.optionals withOpenJpeg [ + "-DUSE_OPENJPEG=ON" + "-DOpenJPEG_DIR=${openjpeg}/lib/${openjpeg.pname}-${lib.versions.majorMinor openjpeg.version}" + ] ++ lib.optionals withCloudflareZlib [ + "-DZLIB_IMPLEMENTATION=Cloudflare" + ]; meta = with lib; { description = "DICOM to NIfTI converter"; longDescription = '' - dcm2niix is a designed to convert neuroimaging data from the - DICOM format to the NIfTI format. + dcm2niix is designed to convert neuroimaging data from the DICOM format to the NIfTI format. ''; homepage = "https://www.nitrc.org/projects/dcm2nii"; license = licenses.bsd3; - maintainers = [ maintainers.ashgillman ]; + maintainers = with maintainers; [ ashgillman rbreslow ]; platforms = platforms.all; }; } diff --git a/pkgs/applications/science/biology/dcm2niix/dont-fetch-external-libs.patch b/pkgs/applications/science/biology/dcm2niix/dont-fetch-external-libs.patch new file mode 100644 index 0000000000000..493f0fb11f461 --- /dev/null +++ b/pkgs/applications/science/biology/dcm2niix/dont-fetch-external-libs.patch @@ -0,0 +1,36 @@ +diff --git a/SuperBuild/External-CLOUDFLARE-ZLIB.cmake b/SuperBuild/External-CLOUDFLARE-ZLIB.cmake +index 9f064eb..fe74df5 100644 +--- a/SuperBuild/External-CLOUDFLARE-ZLIB.cmake ++++ b/SuperBuild/External-CLOUDFLARE-ZLIB.cmake +@@ -1,8 +1,5 @@ +-set(CLOUDFLARE_BRANCH gcc.amd64) # Cloudflare zlib branch +- + ExternalProject_Add(zlib +- GIT_REPOSITORY "${git_protocol}://github.com/ningfei/zlib.git" +- GIT_TAG "${CLOUDFLARE_BRANCH}" ++ URL file://@cloudflareZlib@ + SOURCE_DIR cloudflare-zlib + BINARY_DIR cloudflare-zlib-build + CMAKE_ARGS +diff --git a/SuperBuild/SuperBuild.cmake b/SuperBuild/SuperBuild.cmake +index 2a0a956..81354a7 100644 +--- a/SuperBuild/SuperBuild.cmake ++++ b/SuperBuild/SuperBuild.cmake +@@ -1,17 +1,3 @@ +-# Check if git exists +-find_package(Git) +-if(NOT GIT_FOUND) +- message(FATAL_ERROR "Cannot find Git. Git is required for Superbuild") +-endif() +- +-# Use git protocol or not +-option(USE_GIT_PROTOCOL "If behind a firewall turn this off to use http instead." ON) +-if(USE_GIT_PROTOCOL) +- set(git_protocol "git") +-else() +- set(git_protocol "https") +-endif() +- + # Basic CMake build settings + if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "Release" CACHE STRING |