nixpkgs/pkgs/applications/video/mplayer/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

232 lines
8.5 KiB
Nix
Raw Normal View History

{ config, lib, stdenv, fetchurl, fetchsvn, pkg-config, freetype, yasm, ffmpeg
2015-03-09 06:58:48 +00:00
, aalibSupport ? true, aalib ? null
2013-08-26 19:16:18 +00:00
, fontconfigSupport ? true, fontconfig ? null, freefont_ttf ? null
, fribidiSupport ? true, fribidi ? null
2019-11-10 16:44:34 +00:00
, x11Support ? true, libX11 ? null, libXext ? null, libGLU, libGL ? null
, xineramaSupport ? true, libXinerama ? null
, xvSupport ? true, libXv ? null
, alsaSupport ? stdenv.isLinux, alsa-lib ? null
, screenSaverSupport ? true, libXScrnSaver ? null
, vdpauSupport ? false, libvdpau ? null
2016-09-14 06:12:22 +00:00
, cddaSupport ? !stdenv.isDarwin, cdparanoia ? null
, dvdnavSupport ? !stdenv.isDarwin, libdvdnav ? null
2017-07-28 06:36:59 +00:00
, dvdreadSupport ? true, libdvdread ? null
, bluraySupport ? true, libbluray ? null
, amrSupport ? false, amrnb ? null, amrwb ? null
, cacaSupport ? true, libcaca ? null
, lameSupport ? true, lame ? null
, speexSupport ? true, speex ? null
, theoraSupport ? true, libtheora ? null
, x264Support ? false, x264 ? null
, jackaudioSupport ? false, libjack2 ? null
2019-02-03 15:31:20 +00:00
, pulseSupport ? config.pulseaudio or false, libpulseaudio ? null
, bs2bSupport ? false, libbs2b ? null
, v4lSupport ? false, libv4l ? null
# For screenshots
, libpngSupport ? true, libpng ? null
, libjpegSupport ? true, libjpeg ? null
, useUnfreeCodecs ? false
2016-09-14 06:12:22 +00:00
, darwin ? null
, buildPackages
}:
2013-08-26 19:16:18 +00:00
assert fontconfigSupport -> (fontconfig != null);
assert (!fontconfigSupport) -> (freefont_ttf != null);
assert fribidiSupport -> (fribidi != null);
2019-11-10 16:44:34 +00:00
assert x11Support -> (libX11 != null && libXext != null && libGLU != null && libGL != null);
assert xineramaSupport -> (libXinerama != null && x11Support);
assert xvSupport -> (libXv != null && x11Support);
assert alsaSupport -> alsa-lib != null;
assert screenSaverSupport -> libXScrnSaver != null;
assert vdpauSupport -> libvdpau != null;
assert cddaSupport -> cdparanoia != null;
assert dvdnavSupport -> libdvdnav != null;
2017-07-28 06:36:59 +00:00
assert dvdreadSupport -> libdvdread != null;
assert bluraySupport -> libbluray != null;
assert amrSupport -> (amrnb != null && amrwb != null);
assert cacaSupport -> libcaca != null;
assert lameSupport -> lame != null;
assert speexSupport -> speex != null;
assert theoraSupport -> libtheora != null;
assert x264Support -> x264 != null;
assert jackaudioSupport -> libjack2 != null;
assert pulseSupport -> libpulseaudio != null;
assert bs2bSupport -> libbs2b != null;
assert libpngSupport -> libpng != null;
assert libjpegSupport -> libjpeg != null;
assert v4lSupport -> libv4l != null;
let
codecs_src =
let
dir = "http://www.mplayerhq.hu/MPlayer/releases/codecs/";
2019-09-03 20:51:04 +00:00
version = "20071007";
in
if stdenv.hostPlatform.system == "i686-linux" then fetchurl {
2019-09-03 20:51:04 +00:00
url = "${dir}/essential-${version}.tar.bz2";
sha256 = "18vls12n12rjw0mzw4pkp9vpcfmd1c21rzha19d7zil4hn7fs2ic";
} else if stdenv.hostPlatform.system == "x86_64-linux" then fetchurl {
2019-09-03 20:51:04 +00:00
url = "${dir}/essential-amd64-${version}.tar.bz2";
sha256 = "13xf5b92w1ra5hw00ck151lypbmnylrnznq9hhb0sj36z5wz290x";
} else if stdenv.hostPlatform.system == "powerpc-linux" then fetchurl {
2019-09-03 20:51:04 +00:00
url = "${dir}/essential-ppc-${version}.tar.bz2";
sha256 = "18mlj8dp4wnz42xbhdk1jlz2ygra6fbln9wyrcyvynxh96g1871z";
} else null;
codecs = if codecs_src != null then stdenv.mkDerivation {
2019-09-03 20:51:04 +00:00
pname = "MPlayer-codecs-essential";
src = codecs_src;
installPhase = ''
mkdir $out
cp -prv * $out
'';
2021-01-15 05:42:41 +00:00
meta.license = lib.licenses.unfree;
} else null;
crossBuild = stdenv.hostPlatform != stdenv.buildPlatform;
in
stdenv.mkDerivation rec {
2019-09-03 20:51:04 +00:00
pname = "mplayer";
version = "unstable-2022-02-03";
src = fetchsvn {
url = "svn://svn.mplayerhq.hu/mplayer/trunk";
rev = "38331";
sha256 = "1vpic8i6zvg0zsy50vhm45ysqag561bpn9jycfbvvwl9ji7l55zi";
};
prePatch = ''
sed -i /^_install_strip/d configure
rm -rf ffmpeg
'';
depsBuildBuild = [ buildPackages.stdenv.cc ];
nativeBuildInputs = [ pkg-config yasm ];
2021-01-15 05:42:41 +00:00
buildInputs = with lib;
[ freetype ffmpeg ]
2015-03-09 06:58:48 +00:00
++ optional aalibSupport aalib
2013-08-26 19:16:18 +00:00
++ optional fontconfigSupport fontconfig
++ optional fribidiSupport fribidi
2019-11-10 16:44:34 +00:00
++ optionals x11Support [ libX11 libXext libGLU libGL ]
++ optional alsaSupport alsa-lib
++ optional xvSupport libXv
++ optional theoraSupport libtheora
++ optional cacaSupport libcaca
++ optional xineramaSupport libXinerama
++ optional dvdnavSupport libdvdnav
2017-07-28 06:36:59 +00:00
++ optional dvdreadSupport libdvdread
++ optional bluraySupport libbluray
++ optional cddaSupport cdparanoia
++ optional jackaudioSupport libjack2
++ optionals amrSupport [ amrnb amrwb ]
++ optional x264Support x264
++ optional pulseSupport libpulseaudio
++ optional screenSaverSupport libXScrnSaver
++ optional lameSupport lame
++ optional vdpauSupport libvdpau
++ optional speexSupport speex
++ optional libpngSupport libpng
++ optional libjpegSupport libjpeg
++ optional bs2bSupport libbs2b
++ optional v4lSupport libv4l
2016-09-14 06:12:22 +00:00
++ (with darwin.apple_sdk.frameworks; optionals stdenv.isDarwin [ Cocoa OpenGL ])
;
configurePlatforms = [ ];
2021-01-15 05:42:41 +00:00
configureFlags = with lib; [
"--enable-freetype"
(if fontconfigSupport then "--enable-fontconfig" else "--disable-fontconfig")
(if x11Support then "--enable-x11 --enable-gl" else "--disable-x11 --disable-gl")
(if xineramaSupport then "--enable-xinerama" else "--disable-xinerama")
(if xvSupport then "--enable-xv" else "--disable-xv")
(if alsaSupport then "--enable-alsa" else "--disable-alsa")
(if screenSaverSupport then "--enable-xss" else "--disable-xss")
(if vdpauSupport then "--enable-vdpau" else "--disable-vdpau")
(if cddaSupport then "--enable-cdparanoia" else "--disable-cdparanoia")
(if dvdnavSupport then "--enable-dvdnav" else "--disable-dvdnav")
(if bluraySupport then "--enable-bluray" else "--disable-bluray")
(if amrSupport then "--enable-libopencore_amrnb" else "--disable-libopencore_amrnb")
(if cacaSupport then "--enable-caca" else "--disable-caca")
(if lameSupport then "--enable-mp3lame --disable-mp3lame-lavc" else "--disable-mp3lame --enable-mp3lame-lavc")
(if speexSupport then "--enable-speex" else "--disable-speex")
(if theoraSupport then "--enable-theora" else "--disable-theora")
(if x264Support then "--enable-x264 --disable-x264-lavc" else "--disable-x264 --enable-x264-lavc")
(if jackaudioSupport then "" else "--disable-jack")
(if pulseSupport then "--enable-pulse" else "--disable-pulse")
(if v4lSupport then "--enable-v4l2 --enable-tv-v4l2" else "--disable-v4l2 --disable-tv-v4l2")
"--disable-xanim"
"--disable-xvid --disable-xvid-lavc"
"--disable-ossaudio"
"--disable-ffmpeg_a"
"--yasm=${buildPackages.yasm}/bin/yasm"
# Note, the `target` vs `host` confusion is intensional.
"--target=${stdenv.hostPlatform.config}"
] ++ optional
(useUnfreeCodecs && codecs != null && !crossBuild)
"--codecsdir=${codecs}"
++ optional
(stdenv.hostPlatform.isx86 && !crossBuild)
"--enable-runtime-cpudetection"
++ optional fribidiSupport "--enable-fribidi"
++ optional stdenv.isLinux "--enable-vidix"
++ optional stdenv.isLinux "--enable-fbdev"
++ optionals (crossBuild) [
"--enable-cross-compile"
"--disable-vidix-pcidb"
"--with-vidix-drivers=no"
];
preConfigure = ''
configureFlagsArray+=(
"--cc=$CC"
"--host-cc=$CC_FOR_BUILD"
"--as=$AS"
"--nm=$NM"
"--ar=$AR"
"--ranlib=$RANLIB"
"--windres=$WINDRES"
)
'';
postConfigure = ''
echo CONFIG_MPEGAUDIODSP=yes >> config.mak
'';
2021-01-15 05:42:41 +00:00
NIX_LDFLAGS = with lib; toString (
2013-08-26 19:16:18 +00:00
optional fontconfigSupport "-lfontconfig"
++ optional fribidiSupport "-lfribidi"
2013-08-26 19:16:18 +00:00
++ optionals x11Support [ "-lX11" "-lXext" ]
++ optional x264Support "-lx264"
++ [ "-lfreetype" ]
2019-10-30 00:40:49 +00:00
);
2021-01-15 05:42:41 +00:00
installTargets = [ "install" ] ++ lib.optional x11Support "install-gui";
enableParallelBuilding = true;
2013-08-26 19:16:18 +00:00
# Provide a reasonable standard font when not using fontconfig. Maybe we should symlink here.
2021-01-15 05:42:41 +00:00
postInstall = lib.optionalString (!fontconfigSupport)
''
mkdir -p $out/share/mplayer
cp ${freefont_ttf}/share/fonts/truetype/FreeSans.ttf $out/share/mplayer/subfont.ttf
if test -f $out/share/applications/mplayer.desktop ; then
echo "NoDisplay=True" >> $out/share/applications/mplayer.desktop
fi
'';
meta = with lib; {
description = "A movie player that supports many video formats";
homepage = "http://mplayerhq.hu";
license = licenses.gpl2Only;
maintainers = with maintainers; [ eelco ];
platforms = [ "i686-linux" "x86_64-linux" "x86_64-darwin" "aarch64-darwin" ];
};
}