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