From a0c69fdacbbaca6e5cc98a96d12d0097111783fd Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Fri, 13 Sep 2024 12:22:27 -0400 Subject: [PATCH 1/4] blender: mark as broken on Darwin See comment, tried using apple_sdk_12_3. --- pkgs/applications/misc/blender/default.nix | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkgs/applications/misc/blender/default.nix b/pkgs/applications/misc/blender/default.nix index 09762d8eddac..5c05ac521718 100644 --- a/pkgs/applications/misc/blender/default.nix +++ b/pkgs/applications/misc/blender/default.nix @@ -434,8 +434,7 @@ stdenv.mkDerivation (finalAttrs: { "x86_64-linux" "aarch64-darwin" ]; - # 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"; + broken = stdenv.isDarwin; # fails due to too-old SDK, using newer SDK fails to compile maintainers = with lib.maintainers; [ amarshall veprbl From 12e084743a09350e634ef7b047472ded3fd41a3c Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Fri, 13 Sep 2024 12:23:37 -0400 Subject: [PATCH 2/4] blender: extract conditionals to variables for reuse This gives them some greater semantic meaning, easing understanding (and we will reuse them more soon). In some places, remove duplicate inclusion of the deps in different conditionals to unify them (i.e., include them once based on one conditional, instead of under multiple separate conditionals). --- pkgs/applications/misc/blender/default.nix | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pkgs/applications/misc/blender/default.nix b/pkgs/applications/misc/blender/default.nix index 5c05ac521718..8ad88b906262 100644 --- a/pkgs/applications/misc/blender/default.nix +++ b/pkgs/applications/misc/blender/default.nix @@ -84,6 +84,10 @@ }: let + embreeSupport = (!stdenv.isAarch64 && stdenv.isLinux) || stdenv.isDarwin; + openImageDenoiseSupport = (!stdenv.isAarch64 && stdenv.isLinux) || stdenv.isDarwin; + openUsdSupport = !stdenv.isDarwin; + python3 = python3Packages.python; pyPkgsOpenusd = python3Packages.openusd.override { withOsl = false; }; @@ -193,7 +197,7 @@ stdenv.mkDerivation (finalAttrs: { "-DWITH_GHOST_WAYLAND_DYNLOAD=OFF" "-DWITH_GHOST_WAYLAND_LIBDECOR=ON" ] - ++ lib.optionals (stdenv.hostPlatform.isAarch64 && stdenv.hostPlatform.isLinux) [ + ++ lib.optionals (!embreeSupport) [ "-DWITH_CYCLES_EMBREE=OFF" ] ++ lib.optionals stdenv.isDarwin [ @@ -269,10 +273,8 @@ stdenv.mkDerivation (finalAttrs: { zlib zstd ] - ++ lib.optionals (!stdenv.isAarch64 && stdenv.isLinux) [ - embree - (openimagedenoise.override { inherit cudaSupport; }) - ] + ++ lib.optional embreeSupport embree + ++ lib.optional openImageDenoiseSupport (openimagedenoise.override { inherit cudaSupport; }) ++ ( if (!stdenv.isDarwin) then [ @@ -296,9 +298,7 @@ stdenv.mkDerivation (finalAttrs: { OpenGL SDL brotli - embree llvmPackages.openmp - (openimagedenoise.override { inherit cudaSupport; }) sse2neon ] ) @@ -325,7 +325,7 @@ stdenv.mkDerivation (finalAttrs: { ps.requests ps.zstandard ] - ++ lib.optionals (!stdenv.isDarwin) [ pyPkgsOpenusd ]; + ++ lib.optional openUsdSupport [ pyPkgsOpenusd ]; blenderExecutable = placeholder "out" From 7252a3c5528ba58256618d2f864752607d2e8507 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Fri, 13 Sep 2024 12:29:14 -0400 Subject: [PATCH 3/4] blender: cleanup conditional config Rather than specify things just OFF or ON based on something, always set them to either OFF or ON based on that. --- pkgs/applications/misc/blender/default.nix | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/pkgs/applications/misc/blender/default.nix b/pkgs/applications/misc/blender/default.nix index 8ad88b906262..b87457314403 100644 --- a/pkgs/applications/misc/blender/default.nix +++ b/pkgs/applications/misc/blender/default.nix @@ -167,6 +167,7 @@ stdenv.mkDerivation (finalAttrs: { "-DWITH_CODEC_SNDFILE=ON" "-DWITH_CPU_CHECK=OFF" "-DWITH_CYCLES_DEVICE_OPTIX=${if cudaSupport then "ON" else "OFF"}" + "-DWITH_CYCLES_EMBREE=${if embreeSupport then "ON" else "OFF"}" "-DWITH_CYCLES_OSL=OFF" "-DWITH_FFTW3=ON" "-DWITH_IMAGE_OPENJPEG=ON" @@ -185,7 +186,7 @@ stdenv.mkDerivation (finalAttrs: { "-DWITH_SDL=OFF" "-DWITH_STRICT_BUILD_OPTIONS=ON" "-DWITH_TBB=ON" - "-DWITH_USD=ON" + "-DWITH_USD=${if openUsdSupport then "ON" else "OFF"}" # Blender supplies its own FindAlembic.cmake (incompatible with the Alembic-supplied config file) "-DALEMBIC_INCLUDE_DIR=${lib.getDev alembic}/include" @@ -197,13 +198,9 @@ stdenv.mkDerivation (finalAttrs: { "-DWITH_GHOST_WAYLAND_DYNLOAD=OFF" "-DWITH_GHOST_WAYLAND_LIBDECOR=ON" ] - ++ lib.optionals (!embreeSupport) [ - "-DWITH_CYCLES_EMBREE=OFF" - ] ++ lib.optionals stdenv.isDarwin [ "-DLIBDIR=/does-not-exist" "-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.optionals cudaSupport [ From 88bad969ac63e220055eea815ab35fdf248f9d30 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Fri, 13 Sep 2024 12:29:24 -0400 Subject: [PATCH 4/4] blender: fix build on aarch64-linux --- pkgs/applications/misc/blender/default.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkgs/applications/misc/blender/default.nix b/pkgs/applications/misc/blender/default.nix index b87457314403..503e739a74bd 100644 --- a/pkgs/applications/misc/blender/default.nix +++ b/pkgs/applications/misc/blender/default.nix @@ -170,6 +170,7 @@ stdenv.mkDerivation (finalAttrs: { "-DWITH_CYCLES_EMBREE=${if embreeSupport then "ON" else "OFF"}" "-DWITH_CYCLES_OSL=OFF" "-DWITH_FFTW3=ON" + "-DWITH_HYDRA=${if openUsdSupport then "ON" else "OFF"}" "-DWITH_IMAGE_OPENJPEG=ON" "-DWITH_INSTALL_PORTABLE=OFF" "-DWITH_JACK=${if jackaudioSupport then "ON" else "OFF"}" @@ -177,6 +178,7 @@ stdenv.mkDerivation (finalAttrs: { "-DWITH_MOD_OCEANSIM=ON" "-DWITH_OPENCOLLADA=${if colladaSupport then "ON" else "OFF"}" "-DWITH_OPENCOLORIO=ON" + "-DWITH_OPENIMAGEDENOISE=${if openImageDenoiseSupport then "ON" else "OFF"}" "-DWITH_OPENSUBDIV=ON" "-DWITH_OPENVDB=ON" "-DWITH_PULSEAUDIO=OFF" @@ -284,7 +286,6 @@ stdenv.mkDerivation (finalAttrs: { libXxf86vm openal openxr-loader - pyPkgsOpenusd ] else [ @@ -300,6 +301,7 @@ stdenv.mkDerivation (finalAttrs: { ] ) ++ lib.optionals cudaSupport [ cudaPackages.cuda_cudart ] + ++ lib.optionals openUsdSupport [ pyPkgsOpenusd ] ++ lib.optionals waylandSupport [ dbus libdecor'