nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ stdenv, fetchurl, cmake, libGLU, libGL, libX11, xorgproto, libXt, libtiff
2, fetchpatch
3, qtLib ? null
4, enablePython ? false, python ? null
5# Darwin support
6, Cocoa, CoreServices, DiskArbitration, IOKit, CFNetwork, Security, GLUT, OpenGL
7, ApplicationServices, CoreText, IOSurface, ImageIO, xpc, libobjc }:
8
9with stdenv.lib;
10
11let
12 os = stdenv.lib.optionalString;
13 majorVersion = "8.2";
14 minorVersion = "0";
15 version = "${majorVersion}.${minorVersion}";
16in
17
18stdenv.mkDerivation rec {
19 name = "vtk-${os (qtLib != null) "qvtk-"}${version}";
20 src = fetchurl {
21 url = "${meta.homepage}files/release/${majorVersion}/VTK-${version}.tar.gz";
22 sha256 = "1fspgp8k0myr6p2a6wkc21ldcswb4bvmb484m12mxgk1a9vxrhrl";
23 };
24
25 nativeBuildInputs = [ cmake ];
26
27 buildInputs = [ libtiff ]
28 ++ optionals (qtLib != null) (with qtLib; [ qtbase qtx11extras qttools ])
29 ++ optionals stdenv.isLinux [ libGLU libGL libX11 xorgproto libXt ]
30 ++ optionals stdenv.isDarwin [ xpc Cocoa CoreServices DiskArbitration IOKit
31 CFNetwork Security ApplicationServices CoreText
32 IOSurface ImageIO OpenGL GLUT ]
33 ++ optional enablePython [
34 python
35 ];
36 propagatedBuildInputs = stdenv.lib.optionals stdenv.isDarwin [ libobjc ];
37
38 preBuild = ''
39 export LD_LIBRARY_PATH="$(pwd)/lib";
40 '';
41
42 # Shared libraries don't work, because of rpath troubles with the current
43 # nixpkgs cmake approach. It wants to call a binary at build time, just
44 # built and requiring one of the shared objects.
45 # At least, we use -fPIC for other packages to be able to use this in shared
46 # objects.
47 cmakeFlags = [ "-DCMAKE_C_FLAGS=-fPIC" "-DCMAKE_CXX_FLAGS=-fPIC" "-DVTK_USE_SYSTEM_TIFF=1" "-DOPENGL_INCLUDE_DIR=${libGL}/include" ]
48 ++ optional (qtLib != null) [ "-DVTK_Group_Qt:BOOL=ON" ]
49 ++ optional stdenv.isDarwin [ "-DOPENGL_INCLUDE_DIR=${OpenGL}/Library/Frameworks" ]
50 ++ optional enablePython [ "-DVTK_WRAP_PYTHON:BOOL=ON" ];
51
52 postPatch = stdenv.lib.optionalString stdenv.isDarwin ''
53 sed -i 's|COMMAND vtkHashSource|COMMAND "DYLD_LIBRARY_PATH=''${VTK_BINARY_DIR}/lib" ''${VTK_BINARY_DIR}/bin/vtkHashSource-${majorVersion}|' ./Parallel/Core/CMakeLists.txt
54 sed -i 's/fprintf(output, shift)/fprintf(output, "%s", shift)/' ./ThirdParty/libxml2/vtklibxml2/xmlschemas.c
55 sed -i 's/fprintf(output, shift)/fprintf(output, "%s", shift)/g' ./ThirdParty/libxml2/vtklibxml2/xpath.c
56 '';
57
58 enableParallelBuilding = true;
59
60 meta = {
61 description = "Open source libraries for 3D computer graphics, image processing and visualization";
62 homepage = "https://www.vtk.org/";
63 license = stdenv.lib.licenses.bsd3;
64 maintainers = with stdenv.lib.maintainers; [ knedlsepp ];
65 platforms = with stdenv.lib.platforms; unix;
66 };
67}