lol
at 23.05-pre 101 lines 4.0 kB view raw
1{ majorVersion, minorVersion, sourceSha256, patchesToFetch ? [] }: 2{ stdenv, lib, fetchurl, cmake, libGLU, libGL, libX11, xorgproto, libXt, libpng, libtiff 3, fetchpatch 4, enableQt ? false, qtbase, qtx11extras, qttools, qtdeclarative, qtEnv 5, enablePython ? false, pythonInterpreter ? throw "vtk: Python support requested, but no python interpreter was given." 6# Darwin support 7, Cocoa, CoreServices, DiskArbitration, IOKit, CFNetwork, Security, GLUT, OpenGL 8, ApplicationServices, CoreText, IOSurface, ImageIO, xpc, libobjc 9}: 10 11let 12 inherit (lib) optionalString optionals optional; 13 14 pythonMajor = lib.substring 0 1 pythonInterpreter.pythonVersion; 15 16in stdenv.mkDerivation rec { 17 pname = "vtk${optionalString enableQt "-qvtk"}"; 18 version = "${majorVersion}.${minorVersion}"; 19 20 src = fetchurl { 21 url = "https://www.vtk.org/files/release/${majorVersion}/VTK-${version}.tar.gz"; 22 sha256 = sourceSha256; 23 }; 24 25 nativeBuildInputs = [ cmake ]; 26 27 buildInputs = [ libpng libtiff ] 28 ++ optionals enableQt (if lib.versionOlder majorVersion "9" 29 then [ qtbase qtx11extras qttools ] 30 else [ (qtEnv "qvtk-qt-env" [ qtx11extras qttools qtdeclarative ]) ]) 31 ++ optionals stdenv.isLinux [ 32 libGLU 33 libGL 34 libX11 35 xorgproto 36 libXt 37 ] ++ optionals stdenv.isDarwin [ 38 xpc 39 Cocoa 40 CoreServices 41 DiskArbitration 42 IOKit 43 CFNetwork 44 Security 45 ApplicationServices 46 CoreText 47 IOSurface 48 ImageIO 49 OpenGL 50 GLUT 51 ] ++ optionals enablePython [ 52 pythonInterpreter 53 ]; 54 propagatedBuildInputs = optionals stdenv.isDarwin [ libobjc ]; 55 56 patches = map fetchpatch patchesToFetch; 57 58 dontWrapQtApps = true; 59 60 # Shared libraries don't work, because of rpath troubles with the current 61 # nixpkgs cmake approach. It wants to call a binary at build time, just 62 # built and requiring one of the shared objects. 63 # At least, we use -fPIC for other packages to be able to use this in shared 64 # objects. 65 cmakeFlags = [ 66 "-DCMAKE_C_FLAGS=-fPIC" 67 "-DCMAKE_CXX_FLAGS=-fPIC" 68 "-D${if lib.versionOlder version "9.0" then "VTK_USE_SYSTEM_PNG" else "VTK_MODULE_USE_EXTERNAL_vtkpng"}=ON" 69 "-D${if lib.versionOlder version "9.0" then "VTK_USE_SYSTEM_TIFF" else "VTK_MODULE_USE_EXTERNAL_vtktiff"}=1" 70 "-DOPENGL_INCLUDE_DIR=${libGL}/include" 71 "-DCMAKE_INSTALL_LIBDIR=lib" 72 "-DCMAKE_INSTALL_INCLUDEDIR=include" 73 "-DCMAKE_INSTALL_BINDIR=bin" 74 "-DVTK_VERSIONED_INSTALL=OFF" 75 ] ++ optionals enableQt [ 76 "-D${if lib.versionOlder version "9.0" then "VTK_Group_Qt:BOOL=ON" else "VTK_GROUP_ENABLE_Qt:STRING=YES"}" 77 ] ++ optionals (enableQt && lib.versionOlder version "8.0") [ 78 "-DVTK_QT_VERSION=5" 79 ] 80 ++ optionals stdenv.isDarwin [ "-DOPENGL_INCLUDE_DIR=${OpenGL}/Library/Frameworks" ] 81 ++ optionals enablePython [ 82 "-DVTK_WRAP_PYTHON:BOOL=ON" 83 "-DVTK_PYTHON_VERSION:STRING=${pythonMajor}" 84 ]; 85 86 postPatch = optionalString stdenv.isDarwin '' 87 sed -i 's|COMMAND vtkHashSource|COMMAND "DYLD_LIBRARY_PATH=''${VTK_BINARY_DIR}/lib" ''${VTK_BINARY_DIR}/bin/vtkHashSource-${majorVersion}|' ./Parallel/Core/CMakeLists.txt 88 sed -i 's/fprintf(output, shift)/fprintf(output, "%s", shift)/' ./ThirdParty/libxml2/vtklibxml2/xmlschemas.c 89 sed -i 's/fprintf(output, shift)/fprintf(output, "%s", shift)/g' ./ThirdParty/libxml2/vtklibxml2/xpath.c 90 ''; 91 92 meta = with lib; { 93 description = "Open source libraries for 3D computer graphics, image processing and visualization"; 94 homepage = "https://www.vtk.org/"; 95 license = licenses.bsd3; 96 maintainers = with maintainers; [ knedlsepp tfmoraes lheckemann ]; 97 platforms = with platforms; unix; 98 # /nix/store/xxxxxxx-apple-framework-Security/Library/Frameworks/Security.framework/Headers/Authorization.h:192:7: error: variably modified 'bytes' at file scope 99 broken = stdenv.isDarwin && (lib.versions.major majorVersion == "8"); 100 }; 101}