@@ -2,10 +2,14 @@
22#
33# Derivation patches HandBrake to use Nix closure dependencies.
44#
5+# NOTE: 2019-07-19: This derivation does not currently support the native macOS
6+# GUI--it produces the "HandbrakeCLI" CLI version only. In the future it would
7+# be nice to add the native GUI (and/or the GTK GUI) as an option too, but that
8+# requires invoking the Xcode build system, which is non-trivial for now.
59
610{ stdenv, lib, fetchurl,
711 # Main build tools
8− python2, pkgconfig, autoconf, automake, cmake, nasm, libtool, m4,
12+ python2, pkgconfig, autoconf, automake, cmake, nasm, libtool, m4, lzma,
913 # Processing, video codecs, containers
1014 ffmpeg-full, nv-codec-headers, libogg, x264, x265, libvpx, libtheora,
1115 # Codecs, audio
@@ -14,20 +18,34 @@
1418 libiconv, fribidi, fontconfig, freetype, libass, jansson, libxml2, harfbuzz,
1519 # Optical media
1620 libdvdread, libdvdnav, libdvdcss, libbluray,
17− useGtk ? true, wrapGAppsHook ? null,
18− intltool ? null,
19− glib ? null,
20− gtk3 ? null,
21− libappindicator-gtk3 ? null,
22− libnotify ? null,
23− gst_all_1 ? null,
24− dbus-glib ? null,
25− udev ? null,
26− libgudev ? null,
27− hicolor-icon-theme ? null,
21+ # Darwin-specific
22+ AudioToolbox ? null,
23+ Foundation ? null,
24+ libobjc ? null,
25+ VideoToolbox ? null,
26+ # GTK
27+ # NOTE: 2019-07-19: The gtk3 package has a transitive dependency on dbus,
28+ # which in turn depends on systemd. systemd is not supported on Darwin, so
29+ # for now we disable GTK GUI support on Darwin. (It may be possible to remove
30+ # this restriction later.)
31+ useGtk ? !stdenv.isDarwin, wrapGAppsHook ? null,
32+ intltool ? null,
33+ glib ? null,
34+ gtk3 ? null,
35+ libappindicator-gtk3 ? null,
36+ libnotify ? null,
37+ gst_all_1 ? null,
38+ dbus-glib ? null,
39+ udev ? null,
40+ libgudev ? null,
41+ hicolor-icon-theme ? null,
42+ # FDK
2843 useFdk ? false, fdk_aac ? null
2944}:
3045
46+assert stdenv.isDarwin -> AudioToolbox != null && Foundation != null
47+ && libobjc != null && VideoToolbox != null;
48+
3149stdenv.mkDerivation rec {
3250 pname = "handbrake";
3351 version = "1.2.2";
@@ -45,12 +63,13 @@ stdenv.mkDerivation rec {
4563 ffmpeg-full libogg libtheora x264 x265 libvpx
4664 libopus lame libvorbis a52dec speex libsamplerate
4765 libiconv fribidi fontconfig freetype libass jansson libxml2 harfbuzz
48− libdvdread libdvdnav libdvdcss libbluray
66+ libdvdread libdvdnav libdvdcss libbluray lzma
4967 ] ++ lib.optionals useGtk [
5068 glib gtk3 libappindicator-gtk3 libnotify
5169 gst_all_1.gstreamer gst_all_1.gst-plugins-base dbus-glib udev
5270 libgudev hicolor-icon-theme
5371 ] ++ lib.optional useFdk fdk_aac
72+ ++ lib.optionals stdenv.isDarwin [ AudioToolbox Foundation libobjc VideoToolbox ]
5473 # NOTE: 2018-12-27: Handbrake supports nv-codec-headers for Linux only,
5574 # look at ./make/configure.py search "enable_nvenc"
5675 ++ lib.optional stdenv.isLinux nv-codec-headers;
@@ -59,13 +78,16 @@ stdenv.mkDerivation rec {
5978 # (default distribution bundles&builds 3rd party libs),
6079 # don't trigger cmake build
6180 dontUseCmakeConfigure = true;
62− enableParallelBuilding = true;
81+ # cp: cannot create regular file './internal_defaults.json': File exists
82+ enableParallelBuilding = false;
6383
6484 preConfigure = ''
6585 patchShebangs scripts
6686
6787 substituteInPlace libhb/module.defs \
6888 --replace /usr/include/libxml2 ${libxml2.dev}/include/libxml2
89+ substituteInPlace libhb/module.defs \
90+ --replace '$(CONTRIB.build/)include/libxml2' ${libxml2.dev}/include/libxml2
6991
7092 # Force using nixpkgs dependencies
7193 sed -i '/MODULES += contrib/d' make/include/main.defs
@@ -75,8 +97,9 @@ stdenv.mkDerivation rec {
7597 configureFlags = [
7698 "--disable-df-fetch"
7799 "--disable-df-verify"
78− (if useGtk then "--disable-gtk-update-checks" else "--disable-gtk")
79− (if useFdk then "--enable-fdk-aac" else "")
100+ (if useGtk then "--disable-gtk-update-checks" else "--disable-gtk")
101+ (if useFdk then "--enable-fdk-aac" else "")
102+ (if stdenv.isDarwin then "--disable-xcode" else "")
80103 ];
81104
82105 # NOTE: 2018-12-27: Check NixOS HandBrake test if changing