2021-01-09 10:05:03 +00:00
|
|
|
{ config, stdenv, lib, fetchurl, fetchzip, boost, cmake, ffmpeg, gettext, glew
|
2020-04-24 23:36:52 +00:00
|
|
|
, ilmbase, libXi, libX11, libXext, libXrender
|
|
|
|
, libjpeg, libpng, libsamplerate, libsndfile
|
2021-06-04 09:07:49 +00:00
|
|
|
, libtiff, libGLU, libGL, openal, opencolorio, openexr, openimagedenoise, openimageio2, openjpeg, python39Packages
|
2020-04-24 23:36:52 +00:00
|
|
|
, openvdb, libXxf86vm, tbb, alembic
|
|
|
|
, zlib, fftw, opensubdiv, freetype, jemalloc, ocl-icd, addOpenGLRunpath
|
|
|
|
, jackaudioSupport ? false, libjack2
|
|
|
|
, cudaSupport ? config.cudaSupport or false, cudatoolkit
|
|
|
|
, colladaSupport ? true, opencollada
|
2021-04-05 15:23:46 +00:00
|
|
|
, spaceNavSupport ? stdenv.isLinux, libspnav
|
2020-04-24 23:36:52 +00:00
|
|
|
, makeWrapper
|
2020-11-30 08:33:03 +00:00
|
|
|
, pugixml, llvmPackages, SDL, Cocoa, CoreGraphics, ForceFeedback, OpenAL, OpenGL
|
2021-04-05 15:23:46 +00:00
|
|
|
, potrace
|
|
|
|
, openxr-loader
|
2021-06-28 23:13:55 +00:00
|
|
|
, embree, gmp, libharu
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
with lib;
|
2021-01-09 10:05:03 +00:00
|
|
|
let
|
2021-06-04 09:07:49 +00:00
|
|
|
python = python39Packages.python;
|
2021-01-09 10:05:03 +00:00
|
|
|
optix = fetchzip {
|
|
|
|
url = "https://developer.download.nvidia.com/redist/optix/v7.0/OptiX-7.0.0-include.zip";
|
|
|
|
sha256 = "1b3ccd3197anya2bj3psxdrvrpfgiwva5zfv2xmyrl73nb2dvfr7";
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-01-09 10:05:03 +00:00
|
|
|
in
|
2020-04-24 23:36:52 +00:00
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "blender";
|
2021-08-18 13:19:15 +00:00
|
|
|
version = "2.93.2";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
url = "https://download.blender.org/source/${pname}-${version}.tar.xz";
|
2021-08-18 13:19:15 +00:00
|
|
|
sha256 = "sha256-nG1Kk6UtiCwsQBDz7VELcMRVEovS49QiO3haIpvSfu4=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
patches = lib.optional stdenv.isDarwin ./darwin.patch;
|
|
|
|
|
2021-06-04 09:07:49 +00:00
|
|
|
nativeBuildInputs = [ cmake makeWrapper python39Packages.wrapPython llvmPackages.llvm.dev ]
|
2021-04-12 18:23:04 +00:00
|
|
|
++ optionals cudaSupport [ addOpenGLRunpath ];
|
2020-04-24 23:36:52 +00:00
|
|
|
buildInputs =
|
2020-11-30 08:33:03 +00:00
|
|
|
[ boost ffmpeg gettext glew ilmbase
|
2020-04-24 23:36:52 +00:00
|
|
|
freetype libjpeg libpng libsamplerate libsndfile libtiff
|
|
|
|
opencolorio openexr openimagedenoise openimageio2 openjpeg python zlib fftw jemalloc
|
|
|
|
alembic
|
|
|
|
(opensubdiv.override { inherit cudaSupport; })
|
|
|
|
tbb
|
2020-09-25 04:45:31 +00:00
|
|
|
embree
|
2020-11-30 08:33:03 +00:00
|
|
|
gmp
|
2021-03-23 19:22:30 +00:00
|
|
|
pugixml
|
2021-04-05 15:23:46 +00:00
|
|
|
potrace
|
2021-06-28 23:13:55 +00:00
|
|
|
libharu
|
2020-04-24 23:36:52 +00:00
|
|
|
]
|
|
|
|
++ (if (!stdenv.isDarwin) then [
|
|
|
|
libXi libX11 libXext libXrender
|
|
|
|
libGLU libGL openal
|
|
|
|
libXxf86vm
|
2021-04-05 15:23:46 +00:00
|
|
|
openxr-loader
|
2020-04-24 23:36:52 +00:00
|
|
|
# OpenVDB currently doesn't build on darwin
|
|
|
|
openvdb
|
|
|
|
]
|
|
|
|
else [
|
2021-03-23 19:22:30 +00:00
|
|
|
llvmPackages.openmp SDL Cocoa CoreGraphics ForceFeedback OpenAL OpenGL
|
2020-04-24 23:36:52 +00:00
|
|
|
])
|
|
|
|
++ optional jackaudioSupport libjack2
|
|
|
|
++ optional cudaSupport cudatoolkit
|
2021-03-09 03:18:52 +00:00
|
|
|
++ optional colladaSupport opencollada
|
|
|
|
++ optional spaceNavSupport libspnav;
|
2021-06-04 09:07:49 +00:00
|
|
|
pythonPath = with python39Packages; [ numpy requests ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-09-25 04:45:31 +00:00
|
|
|
postPatch = ''
|
|
|
|
# allow usage of dynamically linked embree
|
|
|
|
rm build_files/cmake/Modules/FindEmbree.cmake
|
|
|
|
'' +
|
|
|
|
(if stdenv.isDarwin then ''
|
2020-04-24 23:36:52 +00:00
|
|
|
: > build_files/cmake/platform/platform_apple_xcode.cmake
|
|
|
|
substituteInPlace source/creator/CMakeLists.txt \
|
|
|
|
--replace '${"$"}{LIBDIR}/python' \
|
2020-11-30 08:33:03 +00:00
|
|
|
'${python}' \
|
|
|
|
--replace '${"$"}{LIBDIR}/openmp' \
|
|
|
|
'${llvmPackages.openmp}'
|
2020-04-24 23:36:52 +00:00
|
|
|
substituteInPlace build_files/cmake/platform/platform_apple.cmake \
|
|
|
|
--replace '${"$"}{LIBDIR}/python' \
|
|
|
|
'${python}' \
|
|
|
|
--replace '${"$"}{LIBDIR}/opencollada' \
|
|
|
|
'${opencollada}' \
|
|
|
|
--replace '${"$"}{PYTHON_LIBPATH}/site-packages/numpy' \
|
2021-06-04 09:07:49 +00:00
|
|
|
'${python39Packages.numpy}/${python.sitePackages}/numpy'
|
2020-04-24 23:36:52 +00:00
|
|
|
'' else ''
|
|
|
|
substituteInPlace extern/clew/src/clew.c --replace '"libOpenCL.so"' '"${ocl-icd}/lib/libOpenCL.so"'
|
2020-09-25 04:45:31 +00:00
|
|
|
'');
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
cmakeFlags =
|
|
|
|
[
|
|
|
|
"-DWITH_ALEMBIC=ON"
|
|
|
|
"-DWITH_MOD_OCEANSIM=ON"
|
|
|
|
"-DWITH_CODEC_FFMPEG=ON"
|
|
|
|
"-DWITH_CODEC_SNDFILE=ON"
|
|
|
|
"-DWITH_INSTALL_PORTABLE=OFF"
|
|
|
|
"-DWITH_FFTW3=ON"
|
|
|
|
"-DWITH_SDL=OFF"
|
|
|
|
"-DWITH_OPENCOLORIO=ON"
|
|
|
|
"-DWITH_OPENSUBDIV=ON"
|
2020-06-18 07:06:33 +00:00
|
|
|
"-DPYTHON_LIBRARY=${python.libPrefix}"
|
2020-04-24 23:36:52 +00:00
|
|
|
"-DPYTHON_LIBPATH=${python}/lib"
|
2020-06-18 07:06:33 +00:00
|
|
|
"-DPYTHON_INCLUDE_DIR=${python}/include/${python.libPrefix}"
|
2020-04-24 23:36:52 +00:00
|
|
|
"-DPYTHON_VERSION=${python.pythonVersion}"
|
|
|
|
"-DWITH_PYTHON_INSTALL=OFF"
|
|
|
|
"-DWITH_PYTHON_INSTALL_NUMPY=OFF"
|
2021-06-04 09:07:49 +00:00
|
|
|
"-DPYTHON_NUMPY_PATH=${python39Packages.numpy}/${python.sitePackages}"
|
|
|
|
"-DPYTHON_NUMPY_INCLUDE_DIRS=${python39Packages.numpy}/${python.sitePackages}/numpy/core/include"
|
2021-04-12 18:23:04 +00:00
|
|
|
"-DWITH_PYTHON_INSTALL_REQUESTS=OFF"
|
2020-04-24 23:36:52 +00:00
|
|
|
"-DWITH_OPENVDB=ON"
|
|
|
|
"-DWITH_TBB=ON"
|
|
|
|
"-DWITH_IMAGE_OPENJPEG=ON"
|
|
|
|
"-DWITH_OPENCOLLADA=${if colladaSupport then "ON" else "OFF"}"
|
|
|
|
]
|
|
|
|
++ optionals stdenv.isDarwin [
|
|
|
|
"-DWITH_CYCLES_OSL=OFF" # requires LLVM
|
|
|
|
"-DWITH_OPENVDB=OFF" # OpenVDB currently doesn't build on darwin
|
|
|
|
|
|
|
|
"-DLIBDIR=/does-not-exist"
|
|
|
|
]
|
|
|
|
# Clang doesn't support "-export-dynamic"
|
|
|
|
++ optional stdenv.cc.isClang "-DPYTHON_LINKFLAGS="
|
|
|
|
++ optional jackaudioSupport "-DWITH_JACK=ON"
|
2021-01-09 10:05:03 +00:00
|
|
|
++ optional cudaSupport [
|
|
|
|
"-DWITH_CYCLES_CUDA_BINARIES=ON"
|
|
|
|
"-DWITH_CYCLES_DEVICE_OPTIX=ON"
|
|
|
|
"-DOPTIX_ROOT_DIR=${optix}"
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
NIX_CFLAGS_COMPILE = "-I${ilmbase.dev}/include/OpenEXR -I${python}/include/${python.libPrefix}";
|
|
|
|
|
|
|
|
# Since some dependencies are built with gcc 6, we need gcc 6's
|
|
|
|
# libstdc++ in our RPATH. Sigh.
|
|
|
|
NIX_LDFLAGS = optionalString cudaSupport "-rpath ${stdenv.cc.cc.lib}/lib";
|
|
|
|
|
|
|
|
blenderExecutable =
|
2021-10-04 12:37:57 +00:00
|
|
|
placeholder "out" + (if stdenv.isDarwin then "/Applications/Blender.app/Contents/MacOS/Blender" else "/bin/blender");
|
|
|
|
postInstall = lib.optionalString stdenv.isDarwin ''
|
|
|
|
mkdir $out/Applications
|
|
|
|
mv $out/Blender.app $out/Applications
|
|
|
|
'' + ''
|
2021-04-12 18:23:04 +00:00
|
|
|
buildPythonPath "$pythonPath"
|
2020-04-24 23:36:52 +00:00
|
|
|
wrapProgram $blenderExecutable \
|
2021-04-12 18:23:04 +00:00
|
|
|
--prefix PATH : $program_PATH \
|
|
|
|
--prefix PYTHONPATH : "$program_PYTHONPATH" \
|
2020-04-24 23:36:52 +00:00
|
|
|
--add-flags '--python-use-system-env'
|
|
|
|
'';
|
|
|
|
|
|
|
|
# Set RUNPATH so that libcuda and libnvrtc in /run/opengl-driver(-32)/lib can be
|
|
|
|
# found. See the explanation in libglvnd.
|
|
|
|
postFixup = optionalString cudaSupport ''
|
|
|
|
for program in $out/bin/blender $out/bin/.blender-wrapped; do
|
|
|
|
isELF "$program" || continue
|
|
|
|
addOpenGLRunpath "$program"
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "3D Creation/Animation/Publishing System";
|
|
|
|
homepage = "https://www.blender.org";
|
|
|
|
# They comment two licenses: GPLv2 and Blender License, but they
|
|
|
|
# say: "We've decided to cancel the BL offering for an indefinite period."
|
2021-01-09 10:05:03 +00:00
|
|
|
# OptiX, enabled with cudaSupport, is non-free.
|
|
|
|
license = with licenses; [ gpl2Plus ] ++ optional cudaSupport unfree;
|
2020-04-24 23:36:52 +00:00
|
|
|
platforms = [ "x86_64-linux" "x86_64-darwin" ];
|
2020-06-18 07:06:33 +00:00
|
|
|
maintainers = with maintainers; [ goibhniu veprbl ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|