summary refs log tree commit diff
path: root/pkgs/applications/video/handbrake/default.nix
diff options
context:
space:
mode:
authorBenjamin Esham <benjamin@esham.io>2020-10-03 05:13:50 -0700
committerGitHub <noreply@github.com>2020-10-03 08:13:50 -0400
commit0e60d79f2a16f24f9836215bcfdb07e0a918735f (patch)
treec156be98414decb1777d0fcd7d381656589fcc22 /pkgs/applications/video/handbrake/default.nix
parentcb4ca8750497cff0874270a1e4abc0a6a5f7daa0 (diff)
downloadnixpkgs-0e60d79f2a16f24f9836215bcfdb07e0a918735f.tar
nixpkgs-0e60d79f2a16f24f9836215bcfdb07e0a918735f.tar.gz
nixpkgs-0e60d79f2a16f24f9836215bcfdb07e0a918735f.tar.bz2
nixpkgs-0e60d79f2a16f24f9836215bcfdb07e0a918735f.tar.lz
nixpkgs-0e60d79f2a16f24f9836215bcfdb07e0a918735f.tar.xz
nixpkgs-0e60d79f2a16f24f9836215bcfdb07e0a918735f.tar.zst
nixpkgs-0e60d79f2a16f24f9836215bcfdb07e0a918735f.zip
handbrake: fix Darwin build (#89674)
- Omit the numactl dependency under Darwin.
- Prevent the configure script from checking for xcodebuild. This check
  always failed (because xcodebuild isn't available in the build
  context) but xcodebuild isn't actually needed for the build, which
  uses --disable-xcode.
- Use the Nix-provided libxml2 under Darwin like we already do under
  Linux.
Diffstat (limited to 'pkgs/applications/video/handbrake/default.nix')
-rw-r--r--pkgs/applications/video/handbrake/default.nix35
1 files changed, 21 insertions, 14 deletions
diff --git a/pkgs/applications/video/handbrake/default.nix b/pkgs/applications/video/handbrake/default.nix
index b56c26dff78..1e4b83da814 100644
--- a/pkgs/applications/video/handbrake/default.nix
+++ b/pkgs/applications/video/handbrake/default.nix
@@ -1,6 +1,6 @@
-# Upstream distributes HandBrake with bundle of according versions of libraries and patches to them.
-#
-# Derivation patches HandBrake to use Nix closure dependencies.
+# Upstream distributes HandBrake with bundle of according versions of libraries
+# and patches to them. This derivation patches HandBrake to use Nix closure
+# dependencies.
 #
 # NOTE: 2019-07-19: This derivation does not currently support the native macOS
 # GUI--it produces the "HandbrakeCLI" CLI version only. In the future it would
@@ -44,11 +44,6 @@
   useFdk ? false, fdk_aac ? null
 }:
 
-assert stdenv.isDarwin -> AudioToolbox != null
-       && Foundation != null
-       && libobjc != null
-       && VideoToolbox != null;
-
 stdenv.mkDerivation rec {
   pname = "handbrake";
   version = "1.3.3";
@@ -76,15 +71,26 @@ _EOF
 
     patchShebangs scripts
 
-    substituteInPlace libhb/module.defs \
-      --replace /usr/include/libxml2 ${libxml2.dev}/include/libxml2
-
     # Force using nixpkgs dependencies
     sed -i '/MODULES += contrib/d' make/include/main.defs
     sed -e 's/^[[:space:]]*\(meson\|ninja\|nasm\)[[:space:]]*= ToolProbe.*$//g' \
         -e '/    ## Additional library and tool checks/,/    ## MinGW specific library and tool checks/d' \
         -i make/configure.py
-  '';
+  '' + (lib.optionalString stdenv.isDarwin ''
+    # Use the Nix-provided libxml2 instead of the patched version available on
+    # the Handbrake website.
+    substituteInPlace libhb/module.defs \
+      --replace '$(CONTRIB.build/)include/libxml2' ${libxml2.dev}/include/libxml2
+
+    # Prevent the configure script from failing if xcodebuild isn't available,
+    # which it isn't in the Nix context. (The actual build goes fine without
+    # xcodebuild.)
+    sed -e '/xcodebuild = ToolProbe/s/abort=.\+)/abort=False)/' -i make/configure.py
+  '') + (lib.optionalString stdenv.isLinux ''
+    # Use the Nix-provided libxml2 instead of the system-provided one.
+    substituteInPlace libhb/module.defs \
+      --replace /usr/include/libxml2 ${libxml2.dev}/include/libxml2
+  '');
 
   nativeBuildInputs = [
     pkgconfig autoconf automake libtool m4 python3
@@ -94,8 +100,9 @@ _EOF
     ffmpeg-full libogg libtheora x264 x265 libvpx dav1d
     libopus lame libvorbis a52dec speex libsamplerate
     libiconv fribidi fontconfig freetype libass jansson libxml2 harfbuzz
-    libdvdread libdvdnav libdvdcss libbluray lzma numactl
-  ] ++ lib.optionals useGtk [
+    libdvdread libdvdnav libdvdcss libbluray lzma
+  ] ++ lib.optional (!stdenv.isDarwin) numactl
+  ++ lib.optionals useGtk [
     glib gtk3 libappindicator-gtk3 libnotify
     gst_all_1.gstreamer gst_all_1.gst-plugins-base dbus-glib udev
     libgudev hicolor-icon-theme