Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 lib, 3 stdenv, 4 fetchFromGitHub, 5 fetchpatch2, 6 cmake, 7 enableVTK ? true, 8 vtk, 9 DarwinTools, # sw_vers 10 enablePython ? false, 11 python ? null, 12 swig, 13 expat, 14 libuuid, 15 openjpeg, 16 zlib, 17 pkg-config, 18 ctestCheckHook, 19}: 20 21stdenv.mkDerivation (finalAttrs: { 22 pname = if enablePython then "python-gdcm" else "gdcm"; 23 version = "3.0.26"; 24 25 src = fetchFromGitHub { 26 owner = "malaterre"; 27 repo = "GDCM"; 28 tag = "v${finalAttrs.version}"; 29 hash = "sha256-GuTxFgK5nfP4l36uqSOMrOkiwTi/T2ywcLh4LDNkKsI="; 30 }; 31 32 patches = [ 33 ./add-missing-losslylosslessarray-in-TestTransferSyntax.patch 34 # Fix vtk deprecated api, See https://docs.vtk.org/en/latest/release_details/9.3.html#id13. 35 # Upstream mailing list: https://sourceforge.net/p/gdcm/mailman/message/59197515. 36 ./fix-vtk-deprecated-api.patch 37 ]; 38 39 cmakeFlags = [ 40 "-DGDCM_BUILD_APPLICATIONS=ON" 41 "-DGDCM_BUILD_SHARED_LIBS=ON" 42 "-DGDCM_BUILD_TESTING=ON" 43 "-DGDCM_USE_SYSTEM_EXPAT=ON" 44 "-DGDCM_USE_SYSTEM_ZLIB=ON" 45 "-DGDCM_USE_SYSTEM_UUID=ON" 46 "-DGDCM_USE_SYSTEM_OPENJPEG=ON" 47 # hack around usual "`RUNTIME_DESTINATION` must not be an absolute path" issue: 48 "-DCMAKE_INSTALL_LIBDIR=lib" 49 "-DCMAKE_INSTALL_BINDIR=bin" 50 "-DCMAKE_INSTALL_INCLUDEDIR=include" 51 ] 52 ++ lib.optionals enableVTK [ 53 "-DGDCM_USE_VTK=ON" 54 ] 55 ++ lib.optionals enablePython [ 56 "-DGDCM_WRAP_PYTHON:BOOL=ON" 57 "-DGDCM_INSTALL_PYTHONMODULE_DIR=${placeholder "out"}/${python.sitePackages}/python_gdcm" 58 ]; 59 60 nativeBuildInputs = [ 61 cmake 62 pkg-config 63 ] 64 ++ lib.optional stdenv.hostPlatform.isDarwin DarwinTools; 65 66 buildInputs = [ 67 expat 68 libuuid 69 openjpeg 70 zlib 71 ] 72 ++ lib.optionals enableVTK [ 73 vtk 74 ] 75 ++ lib.optionals enablePython [ 76 swig 77 python 78 ]; 79 80 postInstall = lib.optionalString enablePython '' 81 substitute \ 82 ${./python_gdcm.egg-info} \ 83 $out/${python.sitePackages}/python_gdcm-${finalAttrs.version}.egg-info \ 84 --subst-var-by GDCM_VER "${finalAttrs.version}" 85 ''; 86 87 disabledTests = [ 88 # require networking: 89 "TestEcho" 90 "TestFind" 91 "gdcmscu-echo-dicomserver" 92 "gdcmscu-find-dicomserver" 93 # seemingly ought to be disabled when the test data submodule is not present: 94 "TestvtkGDCMImageReader2_3" 95 "TestSCUValidation" 96 # errors because 3 classes not wrapped: 97 "TestWrapPython" 98 # AttributeError: module 'gdcm' has no attribute 'UIDGenerator_SetRoot'; maybe a wrapping regression: 99 "TestUIDGeneratorPython" 100 ] 101 ++ lib.optionals (stdenv.hostPlatform.isAarch64 && stdenv.hostPlatform.isLinux) [ 102 "TestRescaler2" 103 ]; 104 105 nativeCheckInputs = [ 106 ctestCheckHook 107 ]; 108 109 doCheck = true; 110 # note that when the test data is available to the build via `fetchSubmodules = true`, 111 # a number of additional but much slower tests are enabled 112 113 meta = { 114 description = "Grassroots cross-platform DICOM implementation"; 115 longDescription = '' 116 Grassroots DICOM (GDCM) is an implementation of the DICOM standard designed to be open source so that researchers may access clinical data directly. 117 GDCM includes a file format definition and a network communications protocol, both of which should be extended to provide a full set of tools for a researcher or small medical imaging vendor to interface with an existing medical database. 118 ''; 119 homepage = "https://gdcm.sourceforge.net"; 120 license = with lib.licenses; [ 121 bsd3 122 asl20 123 ]; 124 maintainers = with lib.maintainers; [ tfmoraes ]; 125 platforms = lib.platforms.all; 126 }; 127})