diff options
Diffstat (limited to 'pkgs/applications/misc/blender/default.nix')
-rw-r--r-- | pkgs/applications/misc/blender/default.nix | 62 |
1 files changed, 39 insertions, 23 deletions
diff --git a/pkgs/applications/misc/blender/default.nix b/pkgs/applications/misc/blender/default.nix index 8cc7d4dd01f61..e54cae9e56a24 100644 --- a/pkgs/applications/misc/blender/default.nix +++ b/pkgs/applications/misc/blender/default.nix @@ -8,12 +8,14 @@ addOpenGLRunpath, alembic, boost, + brotli, callPackage, cmake, colladaSupport ? true, config, cudaPackages, cudaSupport ? config.cudaSupport, + darwin, dbus, embree, fetchurl, @@ -51,6 +53,7 @@ libxkbcommon, llvmPackages, makeWrapper, + materialx, mesa, ocl-icd, openal, @@ -71,6 +74,7 @@ rocmPackages, # comes with a significantly larger closure size runCommand, spaceNavSupport ? stdenv.isLinux, + sse2neon, stdenv, tbb, wayland, @@ -114,15 +118,14 @@ stdenv.mkDerivation (finalAttrs: { '' : > build_files/cmake/platform/platform_apple_xcode.cmake substituteInPlace source/creator/CMakeLists.txt \ - --replace '${"$"}{LIBDIR}/python' \ - '${python3}' - substituteInPlace build_files/cmake/platform/platform_apple.cmake \ - --replace '${"$"}{LIBDIR}/python' \ + --replace-fail '${"$"}{LIBDIR}/python' \ '${python3}' \ - --replace '${"$"}{LIBDIR}/opencollada' \ - '${opencollada}' \ - --replace '${"$"}{PYTHON_LIBPATH}/site-packages/numpy' \ - '${python3Packages.numpy}/${python3.sitePackages}/numpy' + --replace-fail '${"$"}{LIBDIR}/materialx/' '${materialx}/' + substituteInPlace build_files/cmake/platform/platform_apple.cmake \ + --replace-fail '${"$"}{LIBDIR}/brotli/lib/libbrotlicommon-static.a' \ + '${lib.getLib brotli}/lib/libbrotlicommon.dylib' \ + --replace-fail '${"$"}{LIBDIR}/brotli/lib/libbrotlidec-static.a' \ + '${lib.getLib brotli}/lib/libbrotlidec.dylib' '' else '' @@ -150,6 +153,7 @@ stdenv.mkDerivation (finalAttrs: { "-DWITH_FFTW3=ON" "-DWITH_IMAGE_OPENJPEG=ON" "-DWITH_INSTALL_PORTABLE=OFF" + "-DMaterialX_DIR=${materialx}/lib/cmake/MaterialX" "-DWITH_MOD_OCEANSIM=ON" "-DWITH_OPENCOLLADA=${if colladaSupport then "ON" else "OFF"}" "-DWITH_OPENCOLORIO=ON" @@ -164,7 +168,7 @@ stdenv.mkDerivation (finalAttrs: { # Blender supplies its own FindAlembic.cmake (incompatible with the Alembic-supplied config file) "-DALEMBIC_INCLUDE_DIR=${lib.getDev alembic}/include" - "-DALEMBIC_LIBRARY=${lib.getLib alembic}/lib/libAlembic.so" + "-DALEMBIC_LIBRARY=${lib.getLib alembic}/lib/libAlembic${stdenv.hostPlatform.extensions.sharedLibrary}" ] ++ lib.optionals waylandSupport [ "-DWITH_GHOST_WAYLAND=ON" @@ -172,11 +176,12 @@ stdenv.mkDerivation (finalAttrs: { "-DWITH_GHOST_WAYLAND_DYNLOAD=OFF" "-DWITH_GHOST_WAYLAND_LIBDECOR=ON" ] - ++ lib.optionals stdenv.hostPlatform.isAarch64 [ "-DWITH_CYCLES_EMBREE=OFF" ] + ++ lib.optionals (stdenv.hostPlatform.isAarch64 && stdenv.hostPlatform.isLinux) [ "-DWITH_CYCLES_EMBREE=OFF" ] ++ lib.optionals stdenv.isDarwin [ "-DLIBDIR=/does-not-exist" - "-DWITH_CYCLES_OSL=OFF" # requires LLVM - "-DWITH_OPENVDB=OFF" # OpenVDB currently doesn't build on darwin + "-DWITH_CYCLES_OSL=OFF" # causes segfault on aarch64-darwin + "-DSSE2NEON_INCLUDE_DIR=${sse2neon}/lib" + "-DWITH_USD=OFF" # currently fails on darwin ] ++ lib.optional stdenv.cc.isClang "-DPYTHON_LINKFLAGS=" # Clang doesn't support "-export-dynamic" ++ lib.optional jackaudioSupport "-DWITH_JACK=ON" @@ -219,21 +224,22 @@ stdenv.mkDerivation (finalAttrs: { libsndfile libtiff libwebp + materialx opencolorio openexr openimageio openjpeg openpgl (opensubdiv.override { inherit cudaSupport; }) + openvdb potrace pugixml - pyPkgsOpenusd python3 tbb zlib zstd ] - ++ lib.optionals (!stdenv.isAarch64) [ + ++ lib.optionals (!stdenv.isAarch64 && stdenv.isLinux) [ embree (openimagedenoise.override { inherit cudaSupport; }) ] @@ -248,8 +254,8 @@ stdenv.mkDerivation (finalAttrs: { libXrender libXxf86vm openal - openvdb # OpenVDB currently doesn't build on darwin openxr-loader + pyPkgsOpenusd ] else [ @@ -259,7 +265,11 @@ stdenv.mkDerivation (finalAttrs: { OpenAL OpenGL SDL + brotli + embree llvmPackages.openmp + (openimagedenoise.override { inherit cudaSupport; }) + sse2neon ] ) ++ lib.optionals cudaSupport [ cudaPackages.cuda_cudart ] @@ -280,11 +290,12 @@ stdenv.mkDerivation (finalAttrs: { ps = python3Packages; in [ + materialx ps.numpy ps.requests ps.zstandard - pyPkgsOpenusd - ]; + ] + ++ lib.optionals (!stdenv.isDarwin) [ pyPkgsOpenusd ]; blenderExecutable = placeholder "out" @@ -295,8 +306,10 @@ stdenv.mkDerivation (finalAttrs: { mkdir $out/Applications mv $out/Blender.app $out/Applications '' - + '' + + lib.optionalString stdenv.isLinux '' mv $out/share/blender/${lib.versions.majorMinor finalAttrs.version}/python{,-ext} + '' + + '' buildPythonPath "$pythonPath" wrapProgram $blenderExecutable \ --prefix PATH : $program_PATH \ @@ -311,6 +324,9 @@ stdenv.mkDerivation (finalAttrs: { isELF "$program" || continue addOpenGLRunpath "$program" done + '' + + lib.optionalString stdenv.isDarwin '' + makeWrapper $out/Applications/Blender.app/Contents/MacOS/Blender $out/bin/blender ''; passthru = { @@ -327,15 +343,13 @@ stdenv.mkDerivation (finalAttrs: { tests = { render = runCommand "${finalAttrs.pname}-test" { } '' set -euo pipefail - export LIBGL_DRIVERS_PATH=${mesa.drivers}/lib/dri export __EGL_VENDOR_LIBRARY_FILENAMES=${mesa.drivers}/share/glvnd/egl_vendor.d/50_mesa.json - cat <<'PYTHON' > scene-config.py import bpy bpy.context.scene.eevee.taa_render_samples = 32 bpy.context.scene.cycles.samples = 32 - if ${if stdenv.isAarch64 then "True" else "False"}: + if ${if (stdenv.isAarch64 && stdenv.isLinux) then "True" else "False"}: bpy.context.scene.cycles.use_denoising = False bpy.context.scene.render.resolution_x = 100 bpy.context.scene.render.resolution_y = 100 @@ -347,7 +361,7 @@ stdenv.mkDerivation (finalAttrs: { for engine in BLENDER_EEVEE CYCLES; do echo "Rendering with $engine..." # Beware that argument order matters - ${finalAttrs.finalPackage}/bin/blender \ + ${lib.getExe finalAttrs.finalPackage} \ --background \ -noaudio \ --factory-startup \ @@ -372,8 +386,10 @@ stdenv.mkDerivation (finalAttrs: { "aarch64-linux" "x86_64-darwin" "x86_64-linux" + "aarch64-darwin" ]; - broken = stdenv.isDarwin; + # the current apple sdk is too old (currently 11_0) and fails to build "metal" on x86_64-darwin + broken = stdenv.hostPlatform.system == "x86_64-darwin"; maintainers = with lib.maintainers; [ goibhniu veprbl |