summary refs log tree commit diff
path: root/pkgs/applications/video/handbrake/default.nix
diff options
context:
space:
mode:
authorWout Mertens <Wout.Mertens@gmail.com>2014-05-04 01:55:36 +0200
committerWout Mertens <Wout.Mertens@gmail.com>2014-05-04 01:56:49 +0200
commitd93b1f80c034290cc49836030f4f803af70a8f69 (patch)
treed98069eab499047fe22a2af2e1329450083d562b /pkgs/applications/video/handbrake/default.nix
parent3a7b7a8499e8fed3f8d19334a8fd865d0bbd609b (diff)
downloadnixpkgs-d93b1f80c034290cc49836030f4f803af70a8f69.tar
nixpkgs-d93b1f80c034290cc49836030f4f803af70a8f69.tar.gz
nixpkgs-d93b1f80c034290cc49836030f4f803af70a8f69.tar.bz2
nixpkgs-d93b1f80c034290cc49836030f4f803af70a8f69.tar.lz
nixpkgs-d93b1f80c034290cc49836030f4f803af70a8f69.tar.xz
nixpkgs-d93b1f80c034290cc49836030f4f803af70a8f69.tar.zst
nixpkgs-d93b1f80c034290cc49836030f4f803af70a8f69.zip
Add Handbrake 0.9.9: DVD ripper
This packaging splices off the unfree faac library and forces handbrake
to use the (more recent/patched) versions of libraries in Nixpkgs.
Produces the CLI HandbrakeCLI and optionally the GTK+ version ghb.
Diffstat (limited to 'pkgs/applications/video/handbrake/default.nix')
-rw-r--r--pkgs/applications/video/handbrake/default.nix99
1 files changed, 99 insertions, 0 deletions
diff --git a/pkgs/applications/video/handbrake/default.nix b/pkgs/applications/video/handbrake/default.nix
new file mode 100644
index 00000000000..34aa8ff65de
--- /dev/null
+++ b/pkgs/applications/video/handbrake/default.nix
@@ -0,0 +1,99 @@
+# Handbrake normally uses its own copies of the libraries it uses, for better
+# control over library patches.
+#
+# This derivation patches HB so it doesn't do that. The relevant patches
+# are added to the Nix packages and proposed upstream instead. In several cases
+# upstream already incorporated these patches.
+# This has the benefits of providing improvements to other packages,
+# making licenses more clear and reducing compile time/install size.
+#
+# For compliance, the unfree codec faac is optionally spliced out.
+#
+# Only tested on Linux
+#
+# TODO: package and use libappindicator
+
+{ stdenv, config, fetchurl,
+  python, pkgconfig, yasm,
+  autoconf, automake, libtool, m4,
+  libass, libsamplerate, fribidi, libxml2, bzip2,
+  libogg, libtheora, libvorbis, libdvdcss, a52dec, fdk_aac,
+  lame, faac, ffmpeg, libdvdread, libdvdnav, libbluray,
+  mp4v2, mpeg2dec, x264, libmkv,
+  fontconfig, freetype,
+  glib, gtk, webkitgtk, intltool, libnotify,
+  gst_all_1, dbus_glib, udev,
+  useGtk ? true,
+  useWebKitGtk ? false # This prevents ghb from starting in my tests
+}:
+
+stdenv.mkDerivation rec {
+  version = "0.9.9";
+  name = "handbrake-${version}";
+
+  allowUnfree = config.allowUnfree or false;
+
+  buildInputsX = stdenv.lib.optionals useGtk [
+    glib gtk intltool libnotify
+    gst_all_1.gstreamer gst_all_1.gst-plugins-base dbus_glib udev
+  ] ++ stdenv.lib.optionals useWebKitGtk [ webkitgtk ];
+
+  # Did not test compiling with it
+  unfreeInputs = stdenv.lib.optionals allowUnfree [ faac ];
+
+  nativeBuildInputs = [ python pkgconfig yasm autoconf automake libtool m4 ];
+  buildInputs = [
+    fribidi fontconfig freetype
+    libass libsamplerate libxml2 bzip2
+    libogg libtheora libvorbis libdvdcss a52dec libmkv fdk_aac
+    lame ffmpeg libdvdread libdvdnav libbluray mp4v2 mpeg2dec x264
+  ] ++ buildInputsX ++ unfreeInputs;
+
+  
+  src = fetchurl {
+    name = "HandBrake-${version}.tar.bz2";
+    url = "http://handbrake.fr/rotation.php?file=HandBrake-${version}.tar.bz2";
+    sha256 = "1crmm1c32vx60jfl2bqzg59q4qqx6m83b08snp7h1njc21sdf7d7";
+  };
+
+  patches = stdenv.lib.optionals (! allowUnfree) [ ./disable-unfree.patch ];
+
+  preConfigure = ''
+    # Fake wget to prevent downloads
+    mkdir wget
+    echo "#!/bin/sh" > wget/wget
+    echo "echo ===== Not fetching \$*" >> wget/wget
+    echo "exit 1" >> wget/wget
+    chmod +x wget/wget
+    export PATH=$PATH:$PWD/wget
+
+    # Force using nixpkgs dependencies
+    sed -i '/MODULES += contrib/d' make/include/main.defs
+    sed -i '/PKG_CONFIG_PATH=/d' gtk/module.rules
+
+    # disable faac if non-free
+    if [ -z "$allowUnfree" ]; then
+      rm libhb/encfaac.c
+    fi
+  '';
+
+  configureFlags = "--enable-fdk-aac ${if useGtk then "--disable-gtk-update-checks" else "--disable-gtk"}";
+
+  preBuild = ''
+    cd build
+  '';
+
+  meta = {
+    homepage = http://handbrake.fr/;
+    description = "A tool for ripping DVDs into video files";
+    longDescription = ''
+      Handbrake is a versatile transcoding DVD ripper. This package
+      provides the cli HandbrakeCLI and the GTK+ version ghb.
+      The faac library is disabled if you're compiling free-only.
+    '';
+    license = stdenv.lib.licenses.gpl2;
+    maintainers = [ stdenv.lib.maintainers.wmertens ];
+    # Not tested on anything else
+    platforms = stdenv.lib.platforms.linux;
+  };
+}