1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 fetchpatch,
6 cmake,
7 help2man,
8 gzip,
9 libXt,
10 openusd,
11 tbb,
12 vtk,
13 autoPatchelfHook,
14 python3Packages,
15 opencascade-occt,
16 assimp,
17 fontconfig,
18 withManual ? !stdenv.hostPlatform.isDarwin,
19 withPythonBinding ? false,
20 withUsd ? openusd.meta.available,
21}:
22
23stdenv.mkDerivation rec {
24 pname = "f3d";
25 version = "3.2.0";
26
27 outputs = [ "out" ] ++ lib.optionals withManual [ "man" ];
28
29 src = fetchFromGitHub {
30 owner = "f3d-app";
31 repo = "f3d";
32 tag = "v${version}";
33 hash = "sha256-p1Cqam3sYDXJCU1A2sC/fV1ohxS3FGiVrxeGooNXVBQ=";
34 };
35
36 nativeBuildInputs = [
37 cmake
38 ]
39 ++ lib.optionals withManual [
40 # manpage
41 help2man
42 gzip
43 ]
44 ++ lib.optionals stdenv.hostPlatform.isElf [
45 # https://github.com/f3d-app/f3d/pull/1217
46 autoPatchelfHook
47 ];
48
49 buildInputs = [
50 vtk
51 opencascade-occt
52 assimp
53 fontconfig
54 ]
55 ++ lib.optionals withPythonBinding [
56 python3Packages.python
57 # Using C++ header files, not Python import
58 python3Packages.pybind11
59 ]
60 ++ lib.optionals withUsd [
61 libXt
62 openusd
63 tbb
64 ];
65
66 cmakeFlags = [
67 # conflict between VTK and Nixpkgs;
68 # see https://github.com/NixOS/nixpkgs/issues/89167
69 "-DCMAKE_INSTALL_LIBDIR=lib"
70 "-DCMAKE_INSTALL_INCLUDEDIR=include"
71 "-DCMAKE_INSTALL_BINDIR=bin"
72 "-DF3D_MODULE_EXTERNAL_RENDERING=ON"
73 "-DF3D_PLUGIN_BUILD_ASSIMP=ON"
74 "-DF3D_PLUGIN_BUILD_OCCT=ON"
75 ]
76 ++ lib.optionals withManual [
77 "-DF3D_LINUX_GENERATE_MAN=ON"
78 ]
79 ++ lib.optionals withPythonBinding [
80 "-DF3D_BINDINGS_PYTHON=ON"
81 ]
82 ++ lib.optionals withUsd [
83 "-DF3D_PLUGIN_BUILD_USD=ON"
84 ];
85
86 meta = {
87 description = "Fast and minimalist 3D viewer using VTK";
88 homepage = "https://f3d-app.github.io/f3d";
89 changelog = "https://github.com/f3d-app/f3d/releases/tag/v${version}";
90 license = lib.licenses.bsd3;
91 maintainers = with lib.maintainers; [
92 bcdarwin
93 pbsds
94 ];
95 platforms = with lib.platforms; unix;
96 mainProgram = "f3d";
97 };
98}