2020-10-07 09:15:18 +00:00
|
|
|
# Upstream distributes HandBrake with bundle of according versions of libraries
|
|
|
|
# and patches to them. This derivation patches HandBrake to use Nix closure
|
|
|
|
# dependencies.
|
2020-04-24 23:36:52 +00:00
|
|
|
#
|
|
|
|
# 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
|
|
|
|
# be nice to add the native GUI (and/or the GTK GUI) as an option too, but that
|
|
|
|
# requires invoking the Xcode build system, which is non-trivial for now.
|
|
|
|
|
2020-05-29 06:06:01 +00:00
|
|
|
{ stdenv, lib, fetchFromGitHub,
|
2020-04-24 23:36:52 +00:00
|
|
|
# Main build tools
|
2021-04-05 15:23:46 +00:00
|
|
|
pkg-config, autoconf, automake, libtool, m4, xz, python3,
|
2020-04-24 23:36:52 +00:00
|
|
|
numactl,
|
|
|
|
# Processing, video codecs, containers
|
|
|
|
ffmpeg-full, nv-codec-headers, libogg, x264, x265, libvpx, libtheora, dav1d,
|
|
|
|
# Codecs, audio
|
|
|
|
libopus, lame, libvorbis, a52dec, speex, libsamplerate,
|
|
|
|
# Text processing
|
|
|
|
libiconv, fribidi, fontconfig, freetype, libass, jansson, libxml2, harfbuzz,
|
|
|
|
# Optical media
|
|
|
|
libdvdread, libdvdnav, libdvdcss, libbluray,
|
|
|
|
# Darwin-specific
|
|
|
|
AudioToolbox ? null,
|
|
|
|
Foundation ? null,
|
|
|
|
libobjc ? null,
|
|
|
|
VideoToolbox ? null,
|
|
|
|
# GTK
|
|
|
|
# NOTE: 2019-07-19: The gtk3 package has a transitive dependency on dbus,
|
|
|
|
# which in turn depends on systemd. systemd is not supported on Darwin, so
|
|
|
|
# for now we disable GTK GUI support on Darwin. (It may be possible to remove
|
|
|
|
# this restriction later.)
|
|
|
|
useGtk ? !stdenv.isDarwin, wrapGAppsHook ? null,
|
2020-05-29 06:06:01 +00:00
|
|
|
intltool ? null,
|
|
|
|
glib ? null,
|
|
|
|
gtk3 ? null,
|
|
|
|
libappindicator-gtk3 ? null,
|
|
|
|
libnotify ? null,
|
|
|
|
gst_all_1 ? null,
|
|
|
|
dbus-glib ? null,
|
|
|
|
udev ? null,
|
|
|
|
libgudev ? null,
|
|
|
|
hicolor-icon-theme ? null,
|
2020-04-24 23:36:52 +00:00
|
|
|
# FDK
|
|
|
|
useFdk ? false, fdk_aac ? null
|
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "handbrake";
|
2020-06-18 07:06:33 +00:00
|
|
|
version = "1.3.3";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-05-29 06:06:01 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "HandBrake";
|
|
|
|
repo = "HandBrake";
|
|
|
|
rev = version;
|
2020-06-18 07:06:33 +00:00
|
|
|
sha256 = "0bsmk37543zv3p32a7wxnh2w483am23ha2amj339q3nnb4142krn";
|
2020-05-29 06:06:01 +00:00
|
|
|
extraPostFetch = ''
|
|
|
|
echo "DATE=$(date +"%F %T %z" -r $out/NEWS.markdown)" > $out/version.txt
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2020-05-29 06:06:01 +00:00
|
|
|
# we put as little as possible in src.extraPostFetch as it's much easier to
|
|
|
|
# add to it here without having to fiddle with src.sha256
|
|
|
|
# only DATE and HASH are absolutely necessary
|
|
|
|
postPatch = ''
|
|
|
|
cat >> version.txt <<_EOF
|
|
|
|
HASH=${src.rev}
|
|
|
|
SHORTHASH=${src.rev}
|
|
|
|
TAG=${version}
|
|
|
|
URL=${src.meta.homepage}
|
|
|
|
_EOF
|
|
|
|
|
|
|
|
patchShebangs scripts
|
|
|
|
|
|
|
|
# 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
|
2020-10-07 09:15:18 +00:00
|
|
|
'' + (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
|
|
|
|
'');
|
2020-05-29 06:06:01 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
nativeBuildInputs = [
|
2021-02-05 17:12:51 +00:00
|
|
|
pkg-config autoconf automake libtool m4 python3
|
2020-04-24 23:36:52 +00:00
|
|
|
] ++ lib.optionals useGtk [ intltool wrapGAppsHook ];
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
ffmpeg-full libogg libtheora x264 x265 libvpx dav1d
|
|
|
|
libopus lame libvorbis a52dec speex libsamplerate
|
|
|
|
libiconv fribidi fontconfig freetype libass jansson libxml2 harfbuzz
|
2021-04-05 15:23:46 +00:00
|
|
|
libdvdread libdvdnav libdvdcss libbluray xz
|
2020-10-07 09:15:18 +00:00
|
|
|
] ++ lib.optional (!stdenv.isDarwin) numactl
|
|
|
|
++ lib.optionals useGtk [
|
2020-04-24 23:36:52 +00:00
|
|
|
glib gtk3 libappindicator-gtk3 libnotify
|
|
|
|
gst_all_1.gstreamer gst_all_1.gst-plugins-base dbus-glib udev
|
|
|
|
libgudev hicolor-icon-theme
|
|
|
|
] ++ lib.optional useFdk fdk_aac
|
2020-05-29 06:06:01 +00:00
|
|
|
++ lib.optionals stdenv.isDarwin [ AudioToolbox Foundation libobjc VideoToolbox ]
|
2020-04-24 23:36:52 +00:00
|
|
|
# NOTE: 2018-12-27: Handbrake supports nv-codec-headers for Linux only,
|
|
|
|
# look at ./make/configure.py search "enable_nvenc"
|
2020-05-29 06:06:01 +00:00
|
|
|
++ lib.optional stdenv.isLinux nv-codec-headers;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-05-29 06:06:01 +00:00
|
|
|
enableParallelBuilding = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
configureFlags = [
|
|
|
|
"--disable-df-fetch"
|
|
|
|
"--disable-df-verify"
|
|
|
|
(if useGtk then "--disable-gtk-update-checks" else "--disable-gtk")
|
|
|
|
(if useFdk then "--enable-fdk-aac" else "")
|
|
|
|
(if stdenv.isDarwin then "--disable-xcode" else "")
|
2020-05-29 06:06:01 +00:00
|
|
|
] ++ lib.optional (stdenv.isx86_32 || stdenv.isx86_64) "--harden";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# NOTE: 2018-12-27: Check NixOS HandBrake test if changing
|
2020-05-29 06:06:01 +00:00
|
|
|
NIX_LDFLAGS = [
|
2020-04-24 23:36:52 +00:00
|
|
|
"-lx265"
|
|
|
|
];
|
|
|
|
|
|
|
|
preBuild = ''
|
|
|
|
cd build
|
|
|
|
'';
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
homepage = "http://handbrake.fr/";
|
|
|
|
description = "A tool for converting video files and ripping DVDs";
|
|
|
|
longDescription = ''
|
|
|
|
Tool for converting and remuxing video files
|
|
|
|
into selection of modern and widely supported codecs
|
|
|
|
and containers. Very versatile and customizable.
|
|
|
|
Package provides:
|
|
|
|
CLI - `HandbrakeCLI`
|
|
|
|
GTK GUI - `ghb`
|
|
|
|
'';
|
|
|
|
license = licenses.gpl2;
|
|
|
|
maintainers = with maintainers; [ Anton-Latukha wmertens ];
|
|
|
|
platforms = with platforms; unix;
|
|
|
|
};
|
|
|
|
}
|