]> Git — Sourcephile - julm/julm-nix.git/blob - nixpkgs/pkgs/blender/default.nix
sshd: start only after wg-intra
[julm/julm-nix.git] / nixpkgs / pkgs / blender / default.nix
1 { config, stdenv, lib, fetchgit, fetchzip, boost, cmake, ffmpeg, gettext, glew
2 , ilmbase, libXi, libX11, libXext, libXrender
3 , libjpeg, libpng, libsamplerate, libsndfile
4 , libtiff, libGLU, libGL, openal, opencolorio, openexr, openimagedenoise, openimageio2, openjpeg, python39Packages
5 , openvdb, libXxf86vm, tbb, alembic
6 , zlib, fftw, opensubdiv, freetype, jemalloc, ocl-icd, addOpenGLRunpath
7 , jackaudioSupport ? false, libjack2
8 , cudaSupport ? config.cudaSupport or false, cudatoolkit
9 , colladaSupport ? true, opencollada
10 , spaceNavSupport ? stdenv.isLinux, libspnav
11 , makeWrapper
12 , pugixml, llvmPackages, SDL, Cocoa, CoreGraphics, ForceFeedback, OpenAL, OpenGL
13 , potrace
14 , openxr-loader
15 , embree, gmp
16 }:
17
18 with lib;
19 let
20 python = python39Packages.python;
21 optix = fetchzip {
22 url = "https://developer.download.nvidia.com/redist/optix/v7.0/OptiX-7.0.0-include.zip";
23 sha256 = "1b3ccd3197anya2bj3psxdrvrpfgiwva5zfv2xmyrl73nb2dvfr7";
24 };
25
26 in
27 stdenv.mkDerivation rec {
28 pname = "blender";
29 version = "2.93.0";
30
31 src = fetchgit {
32 url = "https://git.blender.org/blender.git";
33 rev = "ec241eb0d020e20924651490a5b74473e347091d";
34 sha256 = "sha256-cQCEn0HggtAspnIy73S9R15HLSrh5wpPrNubEdivLXw=";
35 };
36
37 patches = lib.optional stdenv.isDarwin ./darwin.patch;
38
39 nativeBuildInputs =
40 [ cmake makeWrapper python39Packages.wrapPython ]
41 ++ optional cudaSupport addOpenGLRunpath;
42 buildInputs =
43 [ boost ffmpeg gettext glew ilmbase
44 freetype libjpeg libpng libsamplerate libsndfile libtiff
45 opencolorio openexr openimagedenoise openimageio2 openjpeg python zlib fftw jemalloc
46 alembic
47 (opensubdiv.override { inherit cudaSupport; })
48 tbb
49 embree
50 gmp
51 pugixml
52 potrace
53 ]
54 ++ (if (!stdenv.isDarwin) then [
55 libXi libX11 libXext libXrender
56 libGLU libGL openal
57 libXxf86vm
58 openxr-loader
59 # OpenVDB currently doesn't build on darwin
60 openvdb
61 ]
62 else [
63 llvmPackages.openmp SDL Cocoa CoreGraphics ForceFeedback OpenAL OpenGL
64 ])
65 ++ optional jackaudioSupport libjack2
66 ++ optional cudaSupport cudatoolkit
67 ++ optional colladaSupport opencollada
68 ++ optional spaceNavSupport libspnav;
69 propagatedBuildInputs = with python39Packages; [ numpy requests ];
70
71 postPatch = ''
72 # allow usage of dynamically linked embree
73 rm build_files/cmake/Modules/FindEmbree.cmake
74 '' +
75 (if stdenv.isDarwin then ''
76 : > build_files/cmake/platform/platform_apple_xcode.cmake
77 substituteInPlace source/creator/CMakeLists.txt \
78 --replace '${"$"}{LIBDIR}/python' \
79 '${python}' \
80 --replace '${"$"}{LIBDIR}/openmp' \
81 '${llvmPackages.openmp}'
82 substituteInPlace build_files/cmake/platform/platform_apple.cmake \
83 --replace 'set(PYTHON_VERSION 3.7)' \
84 'set(PYTHON_VERSION ${python.pythonVersion})' \
85 --replace '${"$"}{PYTHON_VERSION}m' \
86 '${"$"}{PYTHON_VERSION}' \
87 --replace '${"$"}{LIBDIR}/python' \
88 '${python}' \
89 --replace '${"$"}{LIBDIR}/opencollada' \
90 '${opencollada}' \
91 --replace '${"$"}{PYTHON_LIBPATH}/site-packages/numpy' \
92 '${python39Packages.numpy}/${python.sitePackages}/numpy' \
93 --replace '${"$"}{PYTHON_LIBPATH}/site-packages/requests' \
94 '${python39Packages.requests}/${python.sitePackages}/requests'
95 '' else ''
96 substituteInPlace extern/clew/src/clew.c --replace '"libOpenCL.so"' '"${ocl-icd}/lib/libOpenCL.so"'
97 '');
98
99 cmakeFlags =
100 [
101 "-DWITH_ALEMBIC=ON"
102 "-DWITH_MOD_OCEANSIM=ON"
103 "-DWITH_CODEC_FFMPEG=ON"
104 "-DWITH_CODEC_SNDFILE=ON"
105 "-DWITH_INSTALL_PORTABLE=OFF"
106 "-DWITH_FFTW3=ON"
107 "-DWITH_SDL=OFF"
108 "-DWITH_OPENCOLORIO=ON"
109 "-DWITH_OPENSUBDIV=ON"
110 "-DPYTHON_LIBRARY=${python.libPrefix}"
111 "-DPYTHON_LIBPATH=${python}/lib"
112 "-DPYTHON_INCLUDE_DIR=${python}/include/${python.libPrefix}"
113 "-DPYTHON_VERSION=${python.pythonVersion}"
114 "-DWITH_PYTHON_INSTALL=OFF"
115 "-DWITH_PYTHON_INSTALL_NUMPY=OFF"
116 "-DPYTHON_NUMPY_INCLUDE_DIRS=${python39Packages.numpy}/${python.sitePackages}/numpy/core/include"
117 "-DPYTHON_NUMPY_PATH=${python39Packages.numpy}/${python.sitePackages}"
118 "-DWITH_PYTHON_INSTALL_REQUESTS=OFF"
119 "-DWITH_OPENVDB=ON"
120 "-DWITH_TBB=ON"
121 "-DWITH_IMAGE_OPENJPEG=ON"
122 "-DWITH_OPENCOLLADA=${if colladaSupport then "ON" else "OFF"}"
123 ]
124 ++ optionals stdenv.isDarwin [
125 "-DWITH_CYCLES_OSL=OFF" # requires LLVM
126 "-DWITH_OPENVDB=OFF" # OpenVDB currently doesn't build on darwin
127
128 "-DLIBDIR=/does-not-exist"
129 ]
130 # Clang doesn't support "-export-dynamic"
131 ++ optional stdenv.cc.isClang "-DPYTHON_LINKFLAGS="
132 ++ optional jackaudioSupport "-DWITH_JACK=ON"
133 ++ optional cudaSupport [
134 "-DWITH_CYCLES_CUDA_BINARIES=ON"
135 "-DWITH_CYCLES_DEVICE_OPTIX=ON"
136 "-DOPTIX_ROOT_DIR=${optix}"
137 ];
138
139 NIX_CFLAGS_COMPILE = "-I${ilmbase.dev}/include/OpenEXR -I${python}/include/${python.libPrefix}";
140
141 # Since some dependencies are built with gcc 6, we need gcc 6's
142 # libstdc++ in our RPATH. Sigh.
143 NIX_LDFLAGS = optionalString cudaSupport "-rpath ${stdenv.cc.cc.lib}/lib";
144
145 blenderExecutable =
146 placeholder "out" + (if stdenv.isDarwin then "/Blender.app/Contents/MacOS/Blender" else "/bin/blender");
147 postInstall = ''
148 buildPythonPath "$propagatedBuildInputs"
149 wrapProgram $blenderExecutable \
150 --prefix PATH : $program_PATH \
151 --prefix PYTHONPATH : "$program_PYTHONPATH" \
152 --add-flags '--python-use-system-env'
153 '';
154
155 # Set RUNPATH so that libcuda and libnvrtc in /run/opengl-driver(-32)/lib can be
156 # found. See the explanation in libglvnd.
157 postFixup = optionalString cudaSupport ''
158 for program in $out/bin/blender $out/bin/.blender-wrapped; do
159 isELF "$program" || continue
160 addOpenGLRunpath "$program"
161 done
162 '';
163
164 meta = with lib; {
165 description = "3D Creation/Animation/Publishing System";
166 homepage = "https://www.blender.org";
167 # They comment two licenses: GPLv2 and Blender License, but they
168 # say: "We've decided to cancel the BL offering for an indefinite period."
169 # OptiX, enabled with cudaSupport, is non-free.
170 license = with licenses; [ gpl2Plus ] ++ optional cudaSupport unfree;
171 platforms = [ "x86_64-linux" "x86_64-darwin" ];
172 maintainers = with maintainers; [ goibhniu veprbl ];
173 };
174 }