2020-10-03 12:13:50 +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.
|
2014-05-03 23:55:36 +00:00
|
|
|
#
|
2019-07-19 17:16:11 +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.
|
2018-05-10 08:14:04 +00:00
|
|
|
|
2021-11-07 01:03:58 +00:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
|
|
|
, fetchFromGitHub
|
|
|
|
, nixosTests
|
2018-12-27 15:40:07 +00:00
|
|
|
# Main build tools
|
2021-11-07 01:03:58 +00:00
|
|
|
, pkg-config
|
|
|
|
, autoconf
|
|
|
|
, automake
|
|
|
|
, libtool
|
|
|
|
, m4
|
|
|
|
, xz
|
|
|
|
, python3
|
|
|
|
, numactl
|
|
|
|
, writeText
|
2018-12-27 15:40:07 +00:00
|
|
|
# Processing, video codecs, containers
|
2021-11-07 01:03:58 +00:00
|
|
|
, ffmpeg-full
|
|
|
|
, nv-codec-headers
|
|
|
|
, libogg
|
|
|
|
, x264
|
|
|
|
, x265
|
|
|
|
, libvpx
|
|
|
|
, libtheora
|
|
|
|
, dav1d
|
|
|
|
, zimg
|
2018-12-27 15:40:07 +00:00
|
|
|
# Codecs, audio
|
2021-11-07 01:03:58 +00:00
|
|
|
, libopus
|
|
|
|
, lame
|
|
|
|
, libvorbis
|
|
|
|
, a52dec
|
|
|
|
, speex
|
|
|
|
, libsamplerate
|
2018-12-27 15:40:07 +00:00
|
|
|
# Text processing
|
2021-11-07 01:03:58 +00:00
|
|
|
, libiconv
|
|
|
|
, fribidi
|
|
|
|
, fontconfig
|
|
|
|
, freetype
|
|
|
|
, libass
|
|
|
|
, jansson
|
|
|
|
, libxml2
|
|
|
|
, harfbuzz
|
|
|
|
, libjpeg_turbo
|
2018-12-27 15:40:07 +00:00
|
|
|
# Optical media
|
2021-11-07 01:03:58 +00:00
|
|
|
, libdvdread
|
|
|
|
, libdvdnav
|
|
|
|
, libdvdcss
|
|
|
|
, libbluray
|
2019-07-19 17:16:11 +00:00
|
|
|
# Darwin-specific
|
2021-11-07 01:03:58 +00:00
|
|
|
, AudioToolbox ? null
|
|
|
|
, Foundation ? null
|
|
|
|
, libobjc ? null
|
|
|
|
, VideoToolbox ? null
|
2019-07-19 17:16:11 +00:00
|
|
|
# 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.)
|
2021-11-07 01:03:58 +00:00
|
|
|
, useGtk ? !stdenv.isDarwin
|
|
|
|
, wrapGAppsHook
|
|
|
|
, intltool
|
|
|
|
, glib
|
|
|
|
, gtk3
|
|
|
|
, libappindicator-gtk3
|
|
|
|
, libnotify
|
|
|
|
, gst_all_1
|
|
|
|
, dbus-glib
|
|
|
|
, udev
|
|
|
|
, libgudev
|
|
|
|
, hicolor-icon-theme
|
2019-07-19 17:16:11 +00:00
|
|
|
# FDK
|
2021-11-07 01:03:58 +00:00
|
|
|
, useFdk ? false
|
|
|
|
, fdk_aac
|
2014-05-03 23:55:36 +00:00
|
|
|
}:
|
|
|
|
|
2021-11-07 01:03:58 +00:00
|
|
|
let
|
|
|
|
version = "1.4.2";
|
2014-05-03 23:55:36 +00:00
|
|
|
|
2020-05-19 04:19:13 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "HandBrake";
|
|
|
|
repo = "HandBrake";
|
|
|
|
rev = version;
|
2021-11-07 01:03:58 +00:00
|
|
|
sha256 = "sha256-Usz2+U1Wb8yJ5W2HqV0FqBaaE25fuVKk/NwKBHaKzwk=";
|
2017-03-18 08:44:45 +00:00
|
|
|
};
|
|
|
|
|
2021-11-07 01:03:58 +00:00
|
|
|
versionFile = writeText "version.txt" ''
|
|
|
|
BRANCH=${versions.majorMinor version}.x
|
|
|
|
DATE=1970-01-01 00:00:01 +0000
|
|
|
|
HASH=${src.rev}
|
|
|
|
REV=${src.rev}
|
|
|
|
SHORTHASH=${src.rev}
|
|
|
|
TAG=${version}
|
|
|
|
URL=${src.meta.homepage}
|
|
|
|
'';
|
|
|
|
|
|
|
|
inherit (lib) optional optionals optionalString versions;
|
|
|
|
|
|
|
|
in
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "handbrake";
|
|
|
|
inherit version src;
|
|
|
|
|
2020-05-19 04:19:13 +00:00
|
|
|
postPatch = ''
|
2021-11-07 01:03:58 +00:00
|
|
|
install -Dm444 ${versionFile} ${versionFile.name}
|
2020-05-19 04:19:13 +00:00
|
|
|
|
|
|
|
patchShebangs scripts
|
|
|
|
|
2021-11-07 01:03:58 +00:00
|
|
|
substituteInPlace libhb/hb.c \
|
|
|
|
--replace 'return hb_version;' 'return "${version}";'
|
|
|
|
|
2020-05-19 04:19:13 +00:00
|
|
|
# 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
|
2021-11-07 01:03:58 +00:00
|
|
|
'' + optionalString stdenv.isDarwin ''
|
2020-10-03 12:13:50 +00:00
|
|
|
# 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
|
2021-11-07 01:03:58 +00:00
|
|
|
'' + optionalString stdenv.isLinux ''
|
2020-10-03 12:13:50 +00:00
|
|
|
# Use the Nix-provided libxml2 instead of the system-provided one.
|
|
|
|
substituteInPlace libhb/module.defs \
|
|
|
|
--replace /usr/include/libxml2 ${libxml2.dev}/include/libxml2
|
2021-11-07 01:03:58 +00:00
|
|
|
'';
|
2020-05-19 04:19:13 +00:00
|
|
|
|
2017-03-18 08:44:45 +00:00
|
|
|
nativeBuildInputs = [
|
2021-11-07 01:03:58 +00:00
|
|
|
autoconf
|
|
|
|
automake
|
|
|
|
libtool
|
|
|
|
m4
|
|
|
|
pkg-config
|
|
|
|
python3
|
|
|
|
]
|
|
|
|
++ optionals useGtk [ intltool wrapGAppsHook ];
|
2014-05-03 23:55:36 +00:00
|
|
|
|
|
|
|
buildInputs = [
|
2021-11-07 01:03:58 +00:00
|
|
|
a52dec
|
|
|
|
dav1d
|
|
|
|
ffmpeg-full
|
|
|
|
fontconfig
|
|
|
|
freetype
|
|
|
|
fribidi
|
|
|
|
harfbuzz
|
|
|
|
jansson
|
|
|
|
lame
|
|
|
|
libass
|
|
|
|
libbluray
|
|
|
|
libdvdcss
|
|
|
|
libdvdnav
|
|
|
|
libdvdread
|
|
|
|
libiconv
|
|
|
|
libjpeg_turbo
|
|
|
|
libogg
|
|
|
|
libopus
|
|
|
|
libsamplerate
|
|
|
|
libtheora
|
|
|
|
libvorbis
|
|
|
|
libvpx
|
|
|
|
libxml2
|
|
|
|
speex
|
|
|
|
x264
|
|
|
|
x265
|
|
|
|
xz
|
|
|
|
zimg
|
|
|
|
]
|
|
|
|
++ optional (!stdenv.isDarwin) numactl
|
|
|
|
++ optionals useGtk [
|
|
|
|
dbus-glib
|
|
|
|
glib
|
|
|
|
gst_all_1.gst-plugins-base
|
|
|
|
gst_all_1.gstreamer
|
|
|
|
gtk3
|
|
|
|
hicolor-icon-theme
|
|
|
|
libappindicator-gtk3
|
|
|
|
libgudev
|
|
|
|
libnotify
|
|
|
|
udev
|
|
|
|
]
|
|
|
|
++ optional useFdk fdk_aac
|
|
|
|
++ optionals stdenv.isDarwin [ AudioToolbox Foundation libobjc VideoToolbox ]
|
2018-12-27 15:40:07 +00:00
|
|
|
# NOTE: 2018-12-27: Handbrake supports nv-codec-headers for Linux only,
|
|
|
|
# look at ./make/configure.py search "enable_nvenc"
|
2021-11-07 01:03:58 +00:00
|
|
|
++ optional stdenv.isLinux nv-codec-headers;
|
2014-05-03 23:55:36 +00:00
|
|
|
|
2016-08-29 06:03:41 +00:00
|
|
|
configureFlags = [
|
2017-03-18 08:44:45 +00:00
|
|
|
"--disable-df-fetch"
|
|
|
|
"--disable-df-verify"
|
2021-11-07 01:03:58 +00:00
|
|
|
"--disable-gtk-update-checks"
|
|
|
|
]
|
|
|
|
++ optional (!useGtk) "--disable-gtk"
|
|
|
|
++ optional useFdk "--enable-fdk-aac"
|
|
|
|
++ optional stdenv.isDarwin "--disable-xcode"
|
|
|
|
++ optional (stdenv.isx86_32 || stdenv.isx86_64) "--harden";
|
2014-05-03 23:55:36 +00:00
|
|
|
|
2018-12-27 15:05:57 +00:00
|
|
|
# NOTE: 2018-12-27: Check NixOS HandBrake test if changing
|
2021-11-07 01:03:58 +00:00
|
|
|
NIX_LDFLAGS = [ "-lx265" ];
|
2017-03-21 10:28:50 +00:00
|
|
|
|
2021-11-07 01:03:58 +00:00
|
|
|
makeFlags = [ "--directory=build" ];
|
|
|
|
|
|
|
|
passthru.tests = {
|
|
|
|
basic-conversion = nixosTests.handbrake;
|
|
|
|
};
|
2014-05-03 23:55:36 +00:00
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
meta = with lib; {
|
2021-11-07 01:03:58 +00:00
|
|
|
homepage = "https://handbrake.fr/";
|
2018-04-18 17:23:27 +00:00
|
|
|
description = "A tool for converting video files and ripping DVDs";
|
2014-05-03 23:55:36 +00:00
|
|
|
longDescription = ''
|
2018-04-18 17:23:27 +00:00
|
|
|
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`
|
2019-09-03 22:49:40 +00:00
|
|
|
GTK GUI - `ghb`
|
2014-05-03 23:55:36 +00:00
|
|
|
'';
|
2021-11-07 01:03:58 +00:00
|
|
|
license = licenses.gpl2Only;
|
2018-04-18 17:23:27 +00:00
|
|
|
maintainers = with maintainers; [ Anton-Latukha wmertens ];
|
2018-05-15 14:43:25 +00:00
|
|
|
platforms = with platforms; unix;
|
2021-11-08 00:50:49 +00:00
|
|
|
broken = stdenv.isDarwin && lib.versionOlder stdenv.hostPlatform.darwinMinVersion "10.13";
|
2014-05-03 23:55:36 +00:00
|
|
|
};
|
|
|
|
}
|