@@ -1,46 +1,115 @@
1−{stdenv, fetchurl, cmake, pkgconfig, libxml2, qt4, gtk, gettext, SDL,
2−libXv, pixman, libpthreadstubs, libXau, libXdmcp, libxslt, x264,
3−alsaLib, lame, faad2, libvorbis, yasm, libvpx, xvidcore, libva,
4−faac ? null, faacSupport ? false }:
1+{ stdenv, lib, fetchurl, cmake, pkgconfig, lndir
2+, zlib, gettext, libvdpau, libva, libXv, sqlite, x265
3+, yasm, fribidi, gtk3, qt4
4+, withX264 ? true, x264
5+, withLAME ? true, lame
6+, withFAAC ? true, faac
7+, withVorbis ? true, libvorbis
8+, withPulse ? true, libpulseaudio
9+, withFAAD ? true, faad2
10+, withOpus ? true, libopus
11+, withVPX ? true, libvpx
12+}:
513
6−assert stdenv ? glibc;
7−assert faacSupport -> faac != null;
8−
9−stdenv.mkDerivation {
10− name = "avidemux-2.5.6";
14+stdenv.mkDerivation rec {
15+ name = "avidemux-${version}";
16+ version = "2.6.12";
1117
1218 src = fetchurl {
13− url = mirror://sourceforge/avidemux/avidemux_2.5.6.tar.gz;
14− sha256 = "12wvxz0n2g85f079d8mdkkp2zm279d34m9v7qgcqndh48cn7znnn";
19+ url = "mirror://sourceforge/avidemux/avidemux/${version}/avidemux_${version}.tar.gz";
20+ sha256 = "0nz52yih8sff53inndkh2dba759xjzsh4b8xjww419lcpk0qp6kn";
1521 };
1622
17− buildInputs = [ cmake pkgconfig libxml2 qt4 gtk gettext SDL libXv
18− pixman libpthreadstubs libXau libXdmcp libxslt x264 alsaLib
19− lame faad2 libvorbis yasm libvpx xvidcore libva
20− ] ++ stdenv.lib.optional faacSupport faac;
23+ nativeBuildInputs = [ cmake pkgconfig yasm lndir ];
24+ buildInputs = [ zlib gettext libvdpau libva libXv sqlite x265 fribidi gtk3 qt4 ]
25+ ++ lib.optional withX264 x264
26+ ++ lib.optional withLAME lame
27+ ++ lib.optional withFAAC faac
28+ ++ lib.optional withVorbis libvorbis
29+ ++ lib.optional withPulse libpulseaudio
30+ ++ lib.optional withFAAD faad2
31+ ++ lib.optional withOpus libopus
32+ ++ lib.optional withVPX libvpx
33+ ;
34+
35+ enableParallelBuilding = false;
36+
37+ outputs = [ "out" "cli" "gtk" "qt4" ];
38+
39+ patches = [ ./dynamic_install_dir.patch ];
40+
41+ buildCommand = ''
42+ unpackPhase
43+ cd "$sourceRoot"
44+ patchPhase
45+
46+ export cmakeFlags="$cmakeFlags -DAVIDEMUX_SOURCE_DIR=$(pwd)"
47+
48+ function buildOutput() {
49+ ( plugin_ui="$1"
50+ output_dir="$2"
51+ shift 2
52+ export cmakeFlags="$cmakeFlags -DPLUGIN_UI=$plugin_ui -DCMAKE_INSTALL_PREFIX=$output_dir"
53+ for i in "$@" avidemux_plugins; do
54+ ( cd "$i"
55+ cmakeConfigurePhase
56+ buildPhase
57+ installPhase
58+ )
59+ done
60+ rm -rf avidemux_plugins/build
61+ )
62+ }
63+
64+ function buildUi() {
65+ plugin_ui="$1"
66+ output_dir="$2"
67+ shift 2
68+
69+ # Hack to split builds properly
70+ mkdir -p $output_dir
71+ lndir $out $output_dir
72+ buildOutput $plugin_ui $output_dir "$@"
73+ }
74+
75+ function fixupUi() {
76+ output_dir="$1"
77+ shift
2178
22− cmakeFlags = "-DPTHREAD_INCLUDE_DIR=${stdenv.glibc}/include" +
23− " -DGETTEXT_INCLUDE_DIR=${gettext}/include" +
24− " -DSDL_INCLUDE_DIR=${SDL}/include/SDL";
79+ find $output_dir -lname $out\* -delete
80+ find $output_dir -type f | while read -r f; do
81+ rpath="$(patchelf --print-rpath $f 2>/dev/null)" || continue
82+ new_rpath=""
83+ IFS=':' read -ra old_rpath <<< "$rpath"
84+ for p in "''${old_rpath[@]}"; do
85+ new_rpath="$new_rpath:$p"
86+ if [[ $p = $output_dir* ]]; then
87+ new_rpath="$new_rpath:$out/''${p#$output_dir}"
88+ fi
89+ done
90+ patchelf --set-rpath "$new_rpath" $f
91+ patchelf --shrink-rpath $f
92+ done
93+ }
2594
26− NIX_LDFLAGS="-lpthread";
95+ buildOutput COMMON $out avidemux_core
96+ buildOutput SETTINGS $out
97+ buildUi CLI $cli avidemux/cli
98+ buildUi GTK $gtk avidemux/gtk
99+ buildUi QT4 $qt4 avidemux/qt4
27100
28− postInstall = ''
29− cd $NIX_BUILD_TOP/$sourceRoot
30− mkdir build_plugins
31− cd build_plugins
32− cmake $cmakeFlags -DAVIDEMUX_INSTALL_PREFIX=$out \
33− -DAVIDEMUX_SOURCE_DIR=$NIX_BUILD_TOP/$sourceRoot \
34− -DAVIDEMUX_CORECONFIG_DIR=$NIX_BUILD_TOP/$sourceRoot/build/config ../plugins
101+ fixupPhase
35102
36− make
37− make install
103+ fixupUi $cli
104+ fixupUi $gtk
105+ fixupUi $qt4
38106 '';
39107
40108 meta = {
41109 homepage = http://fixounet.free.fr/avidemux/;
42110 description = "Free video editor designed for simple video editing tasks";
43− maintainers = with stdenv.lib.maintainers; [viric];
111+ maintainers = with stdenv.lib.maintainers; [ viric abbradar ];
44112 platforms = with stdenv.lib.platforms; linux;
113+ license = stdenv.lib.licenses.gpl2;
45114 };
46115}