From 3ea89d7b62138a17d1c7c1b839334d971bb610e5 Mon Sep 17 00:00:00 2001 From: daspk04 Date: Tue, 9 Jul 2024 02:31:16 +0700 Subject: [PATCH 1/4] maintainers: add @daspk04 --- maintainers/maintainer-list.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix index a7471bcf1934..5af2afd13d08 100644 --- a/maintainers/maintainer-list.nix +++ b/maintainers/maintainer-list.nix @@ -4478,6 +4478,12 @@ githubId = 7589338; name = "Daniel Șerbănescu"; }; + daspk04 = { + email = "dpratyush.k@gmail.com"; + github = "daspk04"; + githubId = 28738918; + name = "Pratyush Das"; + }; datafoo = { github = "datafoo"; githubId = 34766150; From b4fadb9704898fdd49edb39cab8c0fd1f001ef8f Mon Sep 17 00:00:00 2001 From: daspk04 Date: Sun, 17 Nov 2024 12:24:41 +0700 Subject: [PATCH 2/4] itk_4_13: init at 4.13.3 * an old version of itk with extra configuration required for OTB 9.0.0 --- .../ot/otb/itk_4_13/itk-1-fftw-all.diff | 31 ++++ .../ot/otb/itk_4_13/itk-2-itktestlib-all.diff | 35 +++++ ...remove-gcc-version-debian-medteam-all.diff | 104 +++++++++++++ pkgs/by-name/ot/otb/itk_4_13/package.nix | 147 ++++++++++++++++++ 4 files changed, 317 insertions(+) create mode 100644 pkgs/by-name/ot/otb/itk_4_13/itk-1-fftw-all.diff create mode 100644 pkgs/by-name/ot/otb/itk_4_13/itk-2-itktestlib-all.diff create mode 100644 pkgs/by-name/ot/otb/itk_4_13/itk-3-remove-gcc-version-debian-medteam-all.diff create mode 100644 pkgs/by-name/ot/otb/itk_4_13/package.nix diff --git a/pkgs/by-name/ot/otb/itk_4_13/itk-1-fftw-all.diff b/pkgs/by-name/ot/otb/itk_4_13/itk-1-fftw-all.diff new file mode 100644 index 000000000000..8b7769bfb6b1 --- /dev/null +++ b/pkgs/by-name/ot/otb/itk_4_13/itk-1-fftw-all.diff @@ -0,0 +1,31 @@ +diff -burN InsightToolkit-4.10.0.orig/CMake/FindFFTW.cmake InsightToolkit-4.10.0/CMake/FindFFTW.cmake +--- InsightToolkit-4.10.0.orig/CMake/FindFFTW.cmake 2016-06-16 14:21:15.226203872 +0200 ++++ InsightToolkit-4.10.0/CMake/FindFFTW.cmake 2016-06-16 14:23:48.966202670 +0200 +@@ -35,14 +35,12 @@ + set(FFTW_LIB_SEARCHPATH + ${FFTW_INSTALL_BASE_PATH}/lib + ${FFTW_INSTALL_BASE_PATH}/lib64 +- /usr/lib/fftw +- /usr/local/lib/fftw + ) + + if(ITK_USE_FFTWD) + mark_as_advanced(FFTWD_LIB) +- find_library(FFTWD_LIB fftw3 ${FFTW_LIB_SEARCHPATH}) #Double Precision Lib +- find_library(FFTWD_THREADS_LIB fftw3_threads ${FFTW_LIB_SEARCHPATH}) #Double Precision Lib only if compiled with threads support ++ find_library(FFTWD_LIB fftw3 ${FFTW_LIB_SEARCHPATH} NO_DEFAULT_PATH) #Double Precision Lib ++ find_library(FFTWD_THREADS_LIB fftw3_threads ${FFTW_LIB_SEARCHPATH} NO_DEFAULT_PATH) #Double Precision Lib only if compiled with threads support + + if(FFTWD_LIB) + set(FFTWD_FOUND 1) +@@ -55,8 +53,8 @@ + + if(ITK_USE_FFTWF) + mark_as_advanced(FFTWF_LIB) +- find_library(FFTWF_LIB fftw3f ${FFTW_LIB_SEARCHPATH}) #Single Precision Lib +- find_library(FFTWF_THREADS_LIB fftw3f_threads ${FFTW_LIB_SEARCHPATH}) #Single Precision Lib only if compiled with threads support ++ find_library(FFTWF_LIB fftw3f ${FFTW_LIB_SEARCHPATH} NO_DEFAULT_PATH) #Single Precision Lib ++ find_library(FFTWF_THREADS_LIB fftw3f_threads ${FFTW_LIB_SEARCHPATH} NO_DEFAULT_PATH) #Single Precision Lib only if compiled with threads support + + if(FFTWF_LIB) + set(FFTWF_FOUND 1) diff --git a/pkgs/by-name/ot/otb/itk_4_13/itk-2-itktestlib-all.diff b/pkgs/by-name/ot/otb/itk_4_13/itk-2-itktestlib-all.diff new file mode 100644 index 000000000000..dc0b0cbdbb7e --- /dev/null +++ b/pkgs/by-name/ot/otb/itk_4_13/itk-2-itktestlib-all.diff @@ -0,0 +1,35 @@ +diff -burN InsightToolkit-4.12.0.orig/Modules/ThirdParty/VNL/src/CMakeLists.txt InsightToolkit-4.12.0/Modules/ThirdParty/VNL/src/CMakeLists.txt +--- InsightToolkit-4.12.0.orig/Modules/ThirdParty/VNL/src/CMakeLists.txt 2017-08-22 11:53:55.960938649 +0200 ++++ InsightToolkit-4.12.0/Modules/ThirdParty/VNL/src/CMakeLists.txt 2017-08-22 11:56:07.289820954 +0200 +@@ -18,10 +18,14 @@ + # Retrive the variable type to CACHE. + set(BUILD_EXAMPLES ${BUILD_EXAMPLES} CACHE BOOL "Build the examples from the ITK Software Guide." FORCE) + +-foreach(lib itkvcl itkv3p_netlib itktestlib itkvnl itkvnl_algo itknetlib) ++foreach(lib itkvcl itkv3p_netlib itkvnl itkvnl_algo itknetlib) + itk_module_target(${lib} NO_INSTALL) + endforeach() + ++if(BUILD_TESTING) ++ itk_module_target(itktestlib NO_INSTALL) ++endif() ++ + foreach(exe + netlib_integral_test + netlib_lbfgs_example +diff -burN InsightToolkit-4.12.0.orig/Modules/ThirdParty/VNL/src/vxl/core/CMakeLists.txt InsightToolkit-4.12.0/Modules/ThirdParty/VNL/src/vxl/core/CMakeLists.txt +--- InsightToolkit-4.12.0.orig/Modules/ThirdParty/VNL/src/vxl/core/CMakeLists.txt 2017-08-22 11:53:55.960938649 +0200 ++++ InsightToolkit-4.12.0/Modules/ThirdParty/VNL/src/vxl/core/CMakeLists.txt 2017-08-22 11:56:56.410150930 +0200 +@@ -131,8 +131,10 @@ + set(CORE_VIDEO_FOUND OFF CACHE INTERNAL "VXL core video libraries built") + endif () + +-# common test executable +-add_subdirectory(testlib) ++# common test executable if testing enabled ++if(BUILD_TESTING) ++ add_subdirectory(testlib) ++endif() + + # Tests that check and output the vxl configuration + # NOTE: some external projects remove the tests directory (aka ITK) diff --git a/pkgs/by-name/ot/otb/itk_4_13/itk-3-remove-gcc-version-debian-medteam-all.diff b/pkgs/by-name/ot/otb/itk_4_13/itk-3-remove-gcc-version-debian-medteam-all.diff new file mode 100644 index 000000000000..4ee283976202 --- /dev/null +++ b/pkgs/by-name/ot/otb/itk_4_13/itk-3-remove-gcc-version-debian-medteam-all.diff @@ -0,0 +1,104 @@ +--- a/Modules/ThirdParty/VNL/src/vxl/vcl/vcl_compiler.h ++++ b/Modules/ThirdParty/VNL/src/vxl/vcl/vcl_compiler.h +@@ -43,85 +43,7 @@ + #endif + + #if defined(__GNUC__) && !defined(__ICC) // icc 8.0 defines __GNUC__ +-# define VCL_GCC +-# if (__GNUC__ < 4) +-# error "forget it." +-# elif (__GNUC__==4) +-# define VCL_GCC_4 +-# if (__GNUC_MINOR__ > 0 ) +-# define VCL_GCC_41 +-# else +-# define VCL_GCC_40 +-# endif +-# elif (__GNUC__==5) +-# define VCL_GCC_5 +-# if (__GNUC_MINOR__ > 2 ) +-# define VCL_GCC_53 +-# elif (__GNUC_MINOR__ > 1 ) +-# define VCL_GCC_52 +-# elif (__GNUC_MINOR__ > 0 ) +-# define VCL_GCC_51 +-# else +-# define VCL_GCC_50 +-# endif +-# elif (__GNUC__==6) +-# define VCL_GCC_6 +-# if (__GNUC_MINOR__ > 2 ) +-# define VCL_GCC_63 +-# elif (__GNUC_MINOR__ > 1 ) +-# define VCL_GCC_62 +-# elif (__GNUC_MINOR__ > 0 ) +-# define VCL_GCC_61 +-# else +-# define VCL_GCC_60 +-# endif +-# elif (__GNUC__==7) +-# define VCL_GCC_7 +-# if (__GNUC_MINOR__ > 2 ) +-# define VCL_GCC_73 +-# elif (__GNUC_MINOR__ > 1 ) +-# define VCL_GCC_72 +-# elif (__GNUC_MINOR__ > 0 ) +-# define VCL_GCC_71 +-# else +-# define VCL_GCC_70 +-# endif +-# elif (__GNUC__==8) +-# define VCL_GCC_8 +-# if (__GNUC_MINOR__ > 2 ) +-# define VCL_GCC_83 +-# elif (__GNUC_MINOR__ > 1 ) +-# define VCL_GCC_82 +-# elif (__GNUC_MINOR__ > 0 ) +-# define VCL_GCC_81 +-# else +-# define VCL_GCC_80 +-# endif +-# elif (__GNUC__==9) +-# define VCL_GCC_9 +-# if (__GNUC_MINOR__ > 2 ) +-# define VCL_GCC_93 +-# elif (__GNUC_MINOR__ > 1 ) +-# define VCL_GCC_92 +-# elif (__GNUC_MINOR__ > 0 ) +-# define VCL_GCC_91 +-# else +-# define VCL_GCC_90 +-# endif +-# elif (__GNUC__==10) +-# define VCL_GCC_10 +-# if (__GNUC_MINOR__ > 2 ) +-# define VCL_GCC_103 +-# elif (__GNUC_MINOR__ > 1 ) +-# define VCL_GCC_102 +-# elif (__GNUC_MINOR__ > 0 ) +-# define VCL_GCC_101 +-# else +-# define VCL_GCC_100 +-# endif +-# else +-# error "Dunno about this gcc" +-# endif ++# define VCL_GCC_73 + #endif + + #if defined(_WIN32) || defined(WIN32) +--- a/Modules/ThirdParty/VNL/src/vxl/vcl/tests/test_preprocessor.cxx ++++ b/Modules/ThirdParty/VNL/src/vxl/vcl/tests/test_preprocessor.cxx +@@ -64,6 +64,12 @@ + ++minor_count; + #endif + ++#ifdef VCL_GCC_73 ++ ++compiler_count; ++ ++major_count; ++ ++minor_count; ++#endif ++ + #ifdef VCL_VC + ++compiler_count; + #endif diff --git a/pkgs/by-name/ot/otb/itk_4_13/package.nix b/pkgs/by-name/ot/otb/itk_4_13/package.nix new file mode 100644 index 000000000000..54df690fb58a --- /dev/null +++ b/pkgs/by-name/ot/otb/itk_4_13/package.nix @@ -0,0 +1,147 @@ +{ + lib, + stdenv, + fetchFromGitHub, + cmake, + expat, + fftw, + fftwFloat, + hdf5-cpp, + libjpeg, + libtiff, + libpng, + libuuid, + xz, + vtk, + zlib, +}: +# this ITK version is old and is only required for OTB package +# https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/-/blob/develop/SuperBuild/CMake/External_itk.cmake?ref_type=heads#L149 +stdenv.mkDerivation (finalAttrs: { + pname = "itk"; + version = "4.13.3"; + + src = fetchFromGitHub { + owner = "InsightSoftwareConsortium"; + repo = "ITK"; + rev = "v${finalAttrs.version}"; + hash = "sha256-lcoJ+H+nVlvleBqbmupu+yg+4iZQ4mTs9pt1mQac+xg="; + }; + + # https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/-/tree/develop/SuperBuild/patches/ITK?ref_type=heads + patches = [ + ./itk-1-fftw-all.diff + ./itk-2-itktestlib-all.diff + ./itk-3-remove-gcc-version-debian-medteam-all.diff + ]; + + # https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/-/blob/develop/SuperBuild/CMake/External_itk.cmake?ref_type=heads + cmakeFlags = [ + "-DBUILD_TESTING=OFF" + "-DBUILD_EXAMPLES=OFF" + "-DBUILD_SHARED_LIBS=ON" + "-DITK_BUILD_DEFAULT_MODULES=OFF" + "-DITKGroup_Core=OFF" + "-DITK_FORBID_DOWNLOADS=ON" + "-DITK_USE_SYSTEM_LIBRARIES=ON" # finds common libraries e.g. hdf5, libpng, libtiff, libjpeg, zlib etc + "-DModule_ITKCommon=ON" + "-DModule_ITKFiniteDifference=ON" + "-DModule_ITKGPUCommon=ON" + "-DModule_ITKGPUFiniteDifference=ON" + "-DModule_ITKImageAdaptors=ON" + "-DModule_ITKImageFunction=ON" + "-DModule_ITKMesh=ON" + "-DModule_ITKQuadEdgeMesh=ON" + "-DModule_ITKSpatialObjects=ON" + "-DModule_ITKTransform=ON" + "-DModule_ITKTransformFactory=ON" + "-DModule_ITKIOTransformBase=ON" + "-DModule_ITKIOTransformInsightLegacy=ON" + "-DModule_ITKIOTransformMatlab=ON" + "-DModule_ITKAnisotropicSmoothing=ON" + "-DModule_ITKAntiAlias=ON" + "-DModule_ITKBiasCorrection=ON" + "-DModule_ITKBinaryMathematicalMorphology=ON" + "-DModule_ITKColormap=ON" + "-DModule_ITKConvolution=ON" + "-DModule_ITKCurvatureFlow=ON" + "-DModule_ITKDeconvolution=ON" + "-DModule_ITKDenoising=ON" + "-DModule_ITKDisplacementField=ON" + "-DModule_ITKDistanceMap=ON" + "-DModule_ITKFastMarching=ON" + "-DModule_ITKFFT=ON" + "-DModule_ITKGPUAnisotropicSmoothing=ON" + "-DModule_ITKGPUImageFilterBase=ON" + "-DModule_ITKGPUSmoothing=ON" + "-DModule_ITKGPUThresholding=ON" + "-DModule_ITKImageCompare=ON" + "-DModule_ITKImageCompose=ON" + "-DModule_ITKImageFeature=ON" + "-DModule_ITKImageFilterBase=ON" + "-DModule_ITKImageFusion=ON" + "-DModule_ITKImageGradient=ON" + "-DModule_ITKImageGrid=ON" + "-DModule_ITKImageIntensity=ON" + "-DModule_ITKImageLabel=ON" + "-DModule_ITKImageSources=ON" + "-DModule_ITKImageStatistics=ON" + "-DModule_ITKLabelMap=ON" + "-DModule_ITKMathematicalMorphology=ON" + "-DModule_ITKPath=ON" + "-DModule_ITKQuadEdgeMeshFiltering=ON" + "-DModule_ITKSmoothing=ON" + "-DModule_ITKSpatialFunction=ON" + "-DModule_ITKThresholding=ON" + "-DModule_ITKEigen=ON" + "-DModule_ITKNarrowBand=ON" + "-DModule_ITKNeuralNetworks=ON" + "-DModule_ITKOptimizers=ON" + "-DModule_ITKOptimizersv4=ON" + "-DModule_ITKPolynomials=ON" + "-DModule_ITKStatistics=ON" + "-DModule_ITKRegistrationCommon=ON" + "-DModule_ITKGPURegistrationCommon=ON" + "-DModule_ITKGPUPDEDeformableRegistration=ON" + "-DModule_ITKMetricsv4=ON" + "-DModule_ITKPDEDeformableRegistration=ON" + "-DModule_ITKRegistrationMethodsv4=ON" + "-DModule_ITKClassifiers=ON" + "-DModule_ITKConnectedComponents=ON" + "-DModule_ITKDeformableMesh=ON" + "-DModule_ITKKLMRegionGrowing=ON" + "-DModule_ITKLabelVoting=ON" + "-DModule_ITKLevelSets=ON" + "-DModule_ITKLevelSetsv4=ON" + "-DModule_ITKMarkovRandomFieldsClassifiers=ON" + "-DModule_ITKRegionGrowing=ON" + "-DModule_ITKSignedDistanceFunction=ON" + "-DModule_ITKVoronoi=ON" + "-DModule_ITKWatersheds=ON" + ]; + + nativeBuildInputs = [ + cmake + xz + ]; + buildInputs = [ libuuid ]; + propagatedBuildInputs = [ + # similar to 5.2.x, we progagate these inputs for OTB + expat + fftw + fftwFloat + hdf5-cpp + libjpeg + libpng + libtiff + zlib + ]; + + meta = { + description = "Insight Segmentation and Registration Toolkit"; + homepage = "https://www.itk.org"; + license = lib.licenses.asl20; + maintainers = with lib.maintainers; [ daspk04 ]; + platforms = with lib.platforms; linux; + }; +}) From 1d3663186c37011f7fddf817d62a279f03a086ca Mon Sep 17 00:00:00 2001 From: daspk04 Date: Sun, 17 Nov 2024 12:25:46 +0700 Subject: [PATCH 3/4] shark: init at 4.0-unstable-2024-05-25 * init at an unstable version based on commit on 2024-05-25 as no more official release from 4.0.1 onwards. --- pkgs/by-name/sh/shark/package.nix | 47 +++++++++++++++++++ .../sh/shark/shark-1-disable-hdf5-all.diff | 21 +++++++++ .../shark/shark-2-ext-num-literals-all.diff | 13 +++++ 3 files changed, 81 insertions(+) create mode 100644 pkgs/by-name/sh/shark/package.nix create mode 100644 pkgs/by-name/sh/shark/shark-1-disable-hdf5-all.diff create mode 100644 pkgs/by-name/sh/shark/shark-2-ext-num-literals-all.diff diff --git a/pkgs/by-name/sh/shark/package.nix b/pkgs/by-name/sh/shark/package.nix new file mode 100644 index 000000000000..1bd6a9ab94c3 --- /dev/null +++ b/pkgs/by-name/sh/shark/package.nix @@ -0,0 +1,47 @@ +{ + lib, + boost, + cmake, + fetchFromGitHub, + openssl, + stdenv, + enableOpenMP ? false, +}: +stdenv.mkDerivation (finalAttrs: { + pname = "shark"; + version = "4.0-unstable-2024-05-25"; + + src = fetchFromGitHub { + owner = "Shark-ML"; + repo = "Shark"; + rev = "16a7cecf1c012ceaa406e3a5af54d1a6a47d5cda"; + hash = "sha256-xwniI2+Kry04zQqlYjMTp60O6YLibFy+Q/2CY0PHpqs="; + }; + + # https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/-/tree/develop/SuperBuild/patches/SHARK?ref_type=heads + # patch of hdf5 seems to be not needed based on latest master branch of shark as HDF5 has been removed + # c.f https://github.com/Shark-ML/Shark/commit/221c1f2e8abfffadbf3c5ef7cf324bc6dc9b4315 + patches = [ ./shark-2-ext-num-literals-all.diff ]; + + # https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/-/blob/develop/SuperBuild/CMake/External_shark.cmake?ref_type=heads + cmakeFlags = [ + "-DBUILD_SHARED_LIBS=ON" + "-DBUILD_EXAMPLES=OFF" + "-DBUILD_DOCS=OFF" + "-DBUILD_TESTING=OFF" + "-DENABLE_CBLAS=OFF" + ] ++ lib.optionals (!enableOpenMP) [ "-DENABLE_OPENMP=OFF" ]; + buildInputs = [ + boost + openssl + ]; + + nativeBuildInputs = [ cmake ]; + + meta = { + description = "Fast, modular, general open-source C++ machine learning library"; + homepage = "https://shark-ml.github.io/Shark/"; + license = lib.licenses.lgpl3Only; + maintainers = with lib.maintainers; [ daspk04 ]; + }; +}) diff --git a/pkgs/by-name/sh/shark/shark-1-disable-hdf5-all.diff b/pkgs/by-name/sh/shark/shark-1-disable-hdf5-all.diff new file mode 100644 index 000000000000..e7fba1953d4d --- /dev/null +++ b/pkgs/by-name/sh/shark/shark-1-disable-hdf5-all.diff @@ -0,0 +1,21 @@ +diff -burN Shark.orig/CMakeLists.txt Shark/CMakeLists.txt +--- Shark.orig/CMakeLists.txt 2016-09-02 17:04:54.000000000 +0200 ++++ Shark/CMakeLists.txt 2017-07-31 16:41:18.563473752 +0200 +@@ -194,6 +194,8 @@ + ##################################################################### + # HDF5 configuration + ##################################################################### ++option(ENABLE_HDF5 "Use HDF5" ON) ++if(ENABLE_HDF5) + find_package(HDF5 COMPONENTS C CXX HL QUIET) + mark_as_advanced(HDF5_DIR) + if(HDF5_FOUND) +@@ -215,7 +217,7 @@ + else() + message(STATUS "HDF5 not found, skip") + endif() +- ++endif() #ENABLE_HDF5 + ##################################################################### + # ATLAS configuration + ##################################################################### diff --git a/pkgs/by-name/sh/shark/shark-2-ext-num-literals-all.diff b/pkgs/by-name/sh/shark/shark-2-ext-num-literals-all.diff new file mode 100644 index 000000000000..0b964c1b9ada --- /dev/null +++ b/pkgs/by-name/sh/shark/shark-2-ext-num-literals-all.diff @@ -0,0 +1,13 @@ +diff -burN Shark.orig/CMakeLists.txt Shark/CMakeLists.txt +--- Shark.orig/CMakeLists.txt 2018-02-05 18:04:58.012612932 +0100 ++++ Shark/CMakeLists.txt 2018-02-05 18:20:50.032233165 +0100 +@@ -415,6 +415,9 @@ + ##################################################################### + # General Path settings + ##################################################################### ++if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") ++ add_definitions(-fext-numeric-literals) ++endif() + include_directories( ${shark_SOURCE_DIR}/include ) + include_directories( ${shark_BINARY_DIR}/include ) + add_subdirectory( include ) From 5f047b8cc62d67f3074fd1d935300f902347539f Mon Sep 17 00:00:00 2001 From: daspk04 Date: Sun, 17 Nov 2024 12:26:41 +0700 Subject: [PATCH 4/4] otb: init at 9.0.0 --- pkgs/by-name/ot/otb/package.nix | 108 ++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 pkgs/by-name/ot/otb/package.nix diff --git a/pkgs/by-name/ot/otb/package.nix b/pkgs/by-name/ot/otb/package.nix new file mode 100644 index 000000000000..920b11883b72 --- /dev/null +++ b/pkgs/by-name/ot/otb/package.nix @@ -0,0 +1,108 @@ +{ + cmake, + callPackage, + fetchFromGitHub, + makeWrapper, + lib, + stdenv, + swig, + which, + boost, + curl, + gdal, + libsvm, + libgeotiff, + muparser, + muparserx, + opencv, + perl, + python3, + shark, + tinyxml, + enableFeatureExtraction ? true, + enableHyperspectral ? true, + enableLearning ? true, + enableMiscellaneous ? true, + enableOpenMP ? false, + enablePython ? true, + extraPythonPackages ? ps: with ps; [ ], + enableRemote ? true, + enableSAR ? true, + enableSegmentation ? true, + enableStereoProcessing ? true, +}: +let + inherit (lib) optionalString optionals optional; + pythonInputs = + optionals enablePython (with python3.pkgs; [ numpy ]) ++ (extraPythonPackages python3.pkgs); + + otb-itk = callPackage ./itk_4_13/package.nix { }; + otb-shark = shark.override { enableOpenMP = enableOpenMP; }; + +in +stdenv.mkDerivation (finalAttrs: { + pname = "otb"; + version = "9.0.0"; + + src = fetchFromGitHub { + owner = "orfeotoolbox"; + repo = "otb"; + rev = finalAttrs.version; + hash = "sha256-Ut2aimQL6Reg62iceoaM7/nRuEV8PBWtOK7KFHKp0ws="; + }; + + nativeBuildInputs = [ + cmake + makeWrapper + swig + which + ]; + + # https://www.orfeo-toolbox.org/CookBook/CompilingOTBFromSource.html#native-build-with-system-dependencies + # activates all modules and python by default + cmakeFlags = + optional enableFeatureExtraction "-DOTB_BUILD_FeaturesExtraction=ON" + ++ optional enableHyperspectral "-DOTB_BUILD_Hyperspectral=ON" + ++ optional enableLearning "-DOTB_BUILD_Learning=ON" + ++ optional enableMiscellaneous "-DOTB_BUILD_Miscellaneous=ON" + ++ optional enableOpenMP "-DOTB_USE_OPENMP=ON" + ++ optional enableRemote "-DOTB_BUILD_RemoteModules=ON" + ++ optional enableSAR "-DOTB_BUILD_SAR=ON" + ++ optional enableSegmentation "-DOTB_BUILD_Segmentation=ON" + ++ optional enableStereoProcessing "-DOTB_BUILD_StereoProcessing=ON" + ++ optional enablePython "-DOTB_WRAP_PYTHON=ON" + ++ optional finalAttrs.doInstallCheck "-DBUILD_TESTING=ON"; + + propagatedBuildInputs = [ + boost + curl + gdal + libgeotiff + libsvm + muparser + muparserx + opencv + otb-itk + otb-shark + perl + swig + tinyxml + ] ++ optionals enablePython ([ python3 ] ++ pythonInputs); + + doInstallCheck = false; + + pythonPath = optionals enablePython pythonInputs; + + postInstall = '' + wrapProgram $out/bin/otbcli \ + --set OTB_INSTALL_DIR "$out" \ + --set OTB_APPLICATION_PATH "$out/lib/otb/applications" + ''; + + meta = { + description = "Open Source processing of remote sensing images"; + homepage = "https://www.orfeo-toolbox.org/"; + license = lib.licenses.asl20; + maintainers = with lib.maintainers; [ daspk04 ]; + }; +})