2021-11-03 17:39:01 +00:00
|
|
|
{ config
|
|
|
|
, lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
2023-03-13 21:23:47 +00:00
|
|
|
, fetchpatch
|
2021-11-03 17:39:01 +00:00
|
|
|
, addOpenGLRunpath
|
|
|
|
, docutils
|
2022-11-12 18:10:13 +00:00
|
|
|
, meson
|
|
|
|
, ninja
|
2021-11-03 17:39:01 +00:00
|
|
|
, pkg-config
|
|
|
|
, python3
|
2023-01-03 15:02:44 +00:00
|
|
|
, ffmpeg_5
|
2021-11-03 17:39:01 +00:00
|
|
|
, freefont_ttf
|
|
|
|
, freetype
|
|
|
|
, libass
|
|
|
|
, libpthreadstubs
|
|
|
|
, nv-codec-headers
|
|
|
|
, lua
|
|
|
|
, libuchardet
|
2021-11-11 14:08:25 +00:00
|
|
|
, libiconv
|
2022-11-12 18:10:13 +00:00
|
|
|
, xcbuild
|
2016-08-27 04:36:40 +00:00
|
|
|
|
2019-02-03 15:33:13 +00:00
|
|
|
, waylandSupport ? stdenv.isLinux
|
2021-11-11 14:08:25 +00:00
|
|
|
, wayland
|
|
|
|
, wayland-protocols
|
2022-08-27 17:16:55 +00:00
|
|
|
, wayland-scanner
|
2021-11-11 14:08:25 +00:00
|
|
|
, libxkbcommon
|
2016-08-27 04:36:40 +00:00
|
|
|
|
2018-09-04 16:44:01 +00:00
|
|
|
, x11Support ? stdenv.isLinux
|
2021-11-11 14:08:25 +00:00
|
|
|
, libGLU, libGL
|
|
|
|
, libX11
|
|
|
|
, libXext
|
|
|
|
, libXxf86vm
|
|
|
|
, libXrandr
|
2022-08-14 21:03:55 +00:00
|
|
|
, libXpresent
|
2018-09-04 16:44:01 +00:00
|
|
|
|
2018-09-04 16:46:31 +00:00
|
|
|
, cddaSupport ? false
|
2021-11-11 14:08:25 +00:00
|
|
|
, libcdio
|
|
|
|
, libcdio-paranoia
|
2018-09-04 16:46:31 +00:00
|
|
|
|
2019-01-19 00:04:27 +00:00
|
|
|
, vulkanSupport ? stdenv.isLinux
|
2021-11-11 14:08:25 +00:00
|
|
|
, libplacebo
|
2022-11-15 19:58:01 +00:00
|
|
|
, shaderc # instead of spirv-cross
|
2021-11-11 14:08:25 +00:00
|
|
|
, vulkan-headers
|
|
|
|
, vulkan-loader
|
2019-10-25 15:52:58 +00:00
|
|
|
|
|
|
|
, drmSupport ? stdenv.isLinux
|
2021-11-11 14:08:25 +00:00
|
|
|
, libdrm
|
|
|
|
, mesa
|
|
|
|
|
|
|
|
, alsaSupport ? stdenv.isLinux, alsa-lib
|
|
|
|
, archiveSupport ? true, libarchive
|
|
|
|
, bluraySupport ? true, libbluray
|
|
|
|
, bs2bSupport ? true, libbs2b
|
|
|
|
, cacaSupport ? true, libcaca
|
|
|
|
, cmsSupport ? true, lcms2
|
|
|
|
, dvdnavSupport ? stdenv.isLinux, libdvdnav
|
2022-11-15 19:58:01 +00:00
|
|
|
, dvbinSupport ? stdenv.isLinux
|
2021-11-11 14:08:25 +00:00
|
|
|
, jackaudioSupport ? false, libjack2
|
2022-03-13 22:35:37 +00:00
|
|
|
, javascriptSupport ? true, mujs
|
2021-11-11 14:08:25 +00:00
|
|
|
, libpngSupport ? true, libpng
|
|
|
|
, openalSupport ? true, openalSoft
|
|
|
|
, pulseSupport ? config.pulseaudio or stdenv.isLinux, libpulseaudio
|
2022-11-15 19:58:01 +00:00
|
|
|
, pipewireSupport ? stdenv.isLinux, pipewire
|
2022-06-18 22:27:21 +00:00
|
|
|
, rubberbandSupport ? true, rubberband
|
2021-11-11 14:08:25 +00:00
|
|
|
, screenSaverSupport ? true, libXScrnSaver
|
|
|
|
, sdl2Support ? true, SDL2
|
|
|
|
, sixelSupport ? false, libsixel
|
|
|
|
, speexSupport ? true, speex
|
2023-07-25 21:58:02 +00:00
|
|
|
, swiftSupport ? stdenv.isDarwin, swift
|
2021-11-11 14:08:25 +00:00
|
|
|
, theoraSupport ? true, libtheora
|
2023-04-30 00:43:20 +00:00
|
|
|
, vaapiSupport ? x11Support || waylandSupport, libva
|
2021-11-11 14:08:25 +00:00
|
|
|
, vapoursynthSupport ? false, vapoursynth
|
|
|
|
, vdpauSupport ? true, libvdpau
|
|
|
|
, xineramaSupport ? stdenv.isLinux, libXinerama
|
|
|
|
, xvSupport ? stdenv.isLinux, libXv
|
|
|
|
, zimgSupport ? true, zimg
|
2022-12-12 01:34:51 +00:00
|
|
|
, darwin
|
2014-09-27 20:18:42 +00:00
|
|
|
}:
|
2013-12-09 01:25:32 +00:00
|
|
|
|
2016-08-27 04:36:40 +00:00
|
|
|
let
|
2023-04-09 06:21:43 +00:00
|
|
|
inherit (darwin.apple_sdk_11_0.frameworks)
|
|
|
|
AVFoundation CoreFoundation CoreMedia Cocoa CoreAudio MediaPlayer Accelerate;
|
2019-10-25 15:52:58 +00:00
|
|
|
luaEnv = lua.withPackages (ps: with ps; [ luasocket ]);
|
2023-07-25 21:58:02 +00:00
|
|
|
|
|
|
|
overrideSDK = platform: version:
|
|
|
|
platform // lib.optionalAttrs (platform ? darwinMinVersion) {
|
|
|
|
darwinMinVersion = version;
|
|
|
|
};
|
|
|
|
|
|
|
|
stdenv' = if swiftSupport && stdenv.isDarwin && stdenv.isx86_64
|
|
|
|
then stdenv.override (old: {
|
|
|
|
buildPlatform = overrideSDK old.buildPlatform "10.15";
|
|
|
|
hostPlatform = overrideSDK old.hostPlatform "10.15";
|
|
|
|
targetPlatform = overrideSDK old.targetPlatform "10.15";
|
|
|
|
})
|
|
|
|
else stdenv;
|
|
|
|
in stdenv'.mkDerivation (finalAttrs: {
|
2019-08-15 12:41:18 +00:00
|
|
|
pname = "mpv";
|
2023-01-29 02:44:08 +00:00
|
|
|
version = "0.35.1";
|
2013-12-09 01:25:32 +00:00
|
|
|
|
2021-11-03 17:39:01 +00:00
|
|
|
outputs = [ "out" "dev" "man" ];
|
2021-08-22 20:49:20 +00:00
|
|
|
|
2016-08-24 22:47:13 +00:00
|
|
|
src = fetchFromGitHub {
|
2021-11-03 17:39:01 +00:00
|
|
|
owner = "mpv-player";
|
|
|
|
repo = "mpv";
|
2023-04-16 20:09:53 +00:00
|
|
|
rev = "v${finalAttrs.version}";
|
2023-01-29 02:44:08 +00:00
|
|
|
sha256 = "sha256-CoYTX9hgxLo72YdMoa0sEywg4kybHbFsypHk1rCM6tM=";
|
2013-12-09 01:25:32 +00:00
|
|
|
};
|
|
|
|
|
2023-03-13 21:23:47 +00:00
|
|
|
patches = [
|
|
|
|
(fetchpatch {
|
|
|
|
# fixes EDL error on youtube DASH streams https://github.com/mpv-player/mpv/issues/11392
|
|
|
|
# to be removed on next release
|
|
|
|
url = "https://github.com/mpv-player/mpv/commit/94c189dae76ba280d9883b16346c3dfb9720687e.patch";
|
2023-03-17 14:36:37 +00:00
|
|
|
sha256 = "sha256-GeAltLAwkOKk82YfXYSrkNEX08uPauh7+kVbBGPWeT8=";
|
2023-03-13 21:23:47 +00:00
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2017-12-18 16:43:24 +00:00
|
|
|
postPatch = ''
|
2022-11-15 19:58:01 +00:00
|
|
|
patchShebangs version.* ./TOOLS/
|
2015-05-28 13:30:36 +00:00
|
|
|
'';
|
2021-11-11 14:08:25 +00:00
|
|
|
|
2022-11-12 18:10:13 +00:00
|
|
|
NIX_LDFLAGS = lib.optionalString x11Support "-lX11 -lXext ";
|
|
|
|
|
2022-09-08 12:40:45 +00:00
|
|
|
preConfigure = lib.optionalString swiftSupport ''
|
|
|
|
# Ensure we reference 'lib' (not 'out') of Swift.
|
|
|
|
export SWIFT_LIB_DYNAMIC=${lib.getLib swift.swift}/lib/swift/macosx
|
|
|
|
'';
|
|
|
|
|
2022-12-07 21:39:48 +00:00
|
|
|
mesonFlags = [
|
|
|
|
(lib.mesonOption "default_library" "shared")
|
|
|
|
(lib.mesonBool "libmpv" true)
|
|
|
|
(lib.mesonEnable "libarchive" archiveSupport)
|
|
|
|
(lib.mesonEnable "manpage-build" true)
|
|
|
|
(lib.mesonEnable "cdda" cddaSupport)
|
|
|
|
(lib.mesonEnable "dvbin" dvbinSupport)
|
|
|
|
(lib.mesonEnable "dvdnav" dvdnavSupport)
|
|
|
|
(lib.mesonEnable "openal" openalSupport)
|
|
|
|
(lib.mesonEnable "sdl2" sdl2Support)
|
2022-11-12 18:10:13 +00:00
|
|
|
# Disable whilst Swift isn't supported
|
2022-12-07 21:39:48 +00:00
|
|
|
(lib.mesonEnable "swift-build" swiftSupport)
|
|
|
|
(lib.mesonEnable "macos-cocoa-cb" swiftSupport)
|
2022-11-12 18:10:13 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
mesonAutoFeatures = "auto";
|
2015-05-28 13:30:36 +00:00
|
|
|
|
2018-02-27 16:27:46 +00:00
|
|
|
nativeBuildInputs = [
|
2021-11-03 17:39:01 +00:00
|
|
|
addOpenGLRunpath
|
2022-11-15 19:58:01 +00:00
|
|
|
docutils # for rst2man
|
2022-11-12 18:10:13 +00:00
|
|
|
meson
|
|
|
|
ninja
|
2021-11-03 17:39:01 +00:00
|
|
|
pkg-config
|
|
|
|
python3
|
2022-12-07 16:39:17 +00:00
|
|
|
]
|
|
|
|
++ lib.optionals stdenv.isDarwin [ xcbuild.xcrun ]
|
|
|
|
++ lib.optionals swiftSupport [ swift ]
|
|
|
|
++ lib.optionals waylandSupport [ wayland-scanner ];
|
2015-05-28 13:30:36 +00:00
|
|
|
|
|
|
|
buildInputs = [
|
2023-01-03 15:02:44 +00:00
|
|
|
ffmpeg_5
|
2021-11-03 17:39:01 +00:00
|
|
|
freetype
|
|
|
|
libass
|
|
|
|
libpthreadstubs
|
|
|
|
libuchardet
|
|
|
|
luaEnv
|
|
|
|
] ++ lib.optionals alsaSupport [ alsa-lib ]
|
|
|
|
++ lib.optionals archiveSupport [ libarchive ]
|
|
|
|
++ lib.optionals bluraySupport [ libbluray ]
|
|
|
|
++ lib.optionals bs2bSupport [ libbs2b ]
|
|
|
|
++ lib.optionals cacaSupport [ libcaca ]
|
|
|
|
++ lib.optionals cddaSupport [ libcdio libcdio-paranoia ]
|
|
|
|
++ lib.optionals cmsSupport [ lcms2 ]
|
|
|
|
++ lib.optionals drmSupport [ libdrm mesa ]
|
|
|
|
++ lib.optionals dvdnavSupport [ libdvdnav libdvdnav.libdvdread ]
|
|
|
|
++ lib.optionals jackaudioSupport [ libjack2 ]
|
2022-03-13 22:35:37 +00:00
|
|
|
++ lib.optionals javascriptSupport [ mujs ]
|
2021-11-03 17:39:01 +00:00
|
|
|
++ lib.optionals libpngSupport [ libpng ]
|
|
|
|
++ lib.optionals openalSupport [ openalSoft ]
|
2022-11-15 19:58:01 +00:00
|
|
|
++ lib.optionals pipewireSupport [ pipewire ]
|
2021-11-03 17:39:01 +00:00
|
|
|
++ lib.optionals pulseSupport [ libpulseaudio ]
|
|
|
|
++ lib.optionals rubberbandSupport [ rubberband ]
|
|
|
|
++ lib.optionals screenSaverSupport [ libXScrnSaver ]
|
|
|
|
++ lib.optionals sdl2Support [ SDL2 ]
|
|
|
|
++ lib.optionals sixelSupport [ libsixel ]
|
|
|
|
++ lib.optionals speexSupport [ speex ]
|
|
|
|
++ lib.optionals theoraSupport [ libtheora ]
|
|
|
|
++ lib.optionals vaapiSupport [ libva ]
|
|
|
|
++ lib.optionals vapoursynthSupport [ vapoursynth ]
|
|
|
|
++ lib.optionals vdpauSupport [ libvdpau ]
|
|
|
|
++ lib.optionals vulkanSupport [ libplacebo shaderc vulkan-headers vulkan-loader ]
|
|
|
|
++ lib.optionals waylandSupport [ wayland wayland-protocols libxkbcommon ]
|
2022-08-14 21:03:55 +00:00
|
|
|
++ lib.optionals x11Support [ libX11 libXext libGLU libGL libXxf86vm libXrandr libXpresent ]
|
2021-11-03 17:39:01 +00:00
|
|
|
++ lib.optionals xineramaSupport [ libXinerama ]
|
|
|
|
++ lib.optionals xvSupport [ libXv ]
|
|
|
|
++ lib.optionals zimgSupport [ zimg ]
|
|
|
|
++ lib.optionals stdenv.isLinux [ nv-codec-headers ]
|
|
|
|
++ lib.optionals stdenv.isDarwin [ libiconv ]
|
2023-04-09 06:21:43 +00:00
|
|
|
++ lib.optionals stdenv.isDarwin [ CoreFoundation Cocoa CoreAudio MediaPlayer Accelerate ]
|
2022-09-08 12:40:45 +00:00
|
|
|
++ lib.optionals (stdenv.isDarwin && swiftSupport) [ AVFoundation CoreMedia ];
|
2013-12-09 01:25:32 +00:00
|
|
|
|
2021-11-03 17:39:01 +00:00
|
|
|
postBuild = lib.optionalString stdenv.isDarwin ''
|
2022-11-12 18:10:13 +00:00
|
|
|
pushd .. # Must be run from the source dir because it uses relative paths
|
2018-07-16 13:04:10 +00:00
|
|
|
python3 TOOLS/osxbundle.py -s build/mpv
|
2022-11-12 18:10:13 +00:00
|
|
|
popd
|
2013-12-09 01:25:32 +00:00
|
|
|
'';
|
|
|
|
|
2020-02-02 19:06:35 +00:00
|
|
|
postInstall = ''
|
2018-07-16 13:04:10 +00:00
|
|
|
# Use a standard font
|
|
|
|
mkdir -p $out/share/mpv
|
|
|
|
ln -s ${freefont_ttf}/share/fonts/truetype/FreeSans.ttf $out/share/mpv/subfont.ttf
|
2016-11-23 03:52:07 +00:00
|
|
|
|
2022-11-12 18:10:13 +00:00
|
|
|
cp ../TOOLS/mpv_identify.sh $out/bin
|
|
|
|
cp ../TOOLS/umpv $out/bin
|
2020-12-08 00:30:12 +00:00
|
|
|
cp $out/share/applications/mpv.desktop $out/share/applications/umpv.desktop
|
2023-05-20 17:54:53 +00:00
|
|
|
sed -i '/Icon=/ ! s/mpv/umpv/g; s/^Exec=.*/Exec=umpv %U/' $out/share/applications/umpv.desktop
|
2023-07-21 13:13:28 +00:00
|
|
|
printf "NoDisplay=true\n" >> $out/share/applications/umpv.desktop
|
2021-11-03 17:39:01 +00:00
|
|
|
'' + lib.optionalString stdenv.isDarwin ''
|
2018-07-16 13:04:10 +00:00
|
|
|
mkdir -p $out/Applications
|
2022-11-12 18:10:13 +00:00
|
|
|
cp -r mpv.app $out/Applications
|
2015-05-28 13:30:36 +00:00
|
|
|
'';
|
|
|
|
|
2019-08-30 19:54:08 +00:00
|
|
|
# Set RUNPATH so that libcuda in /run/opengl-driver(-32)/lib can be found.
|
|
|
|
# See the explanation in addOpenGLRunpath.
|
2021-11-03 17:39:01 +00:00
|
|
|
postFixup = lib.optionalString stdenv.isLinux ''
|
2020-05-22 17:27:38 +00:00
|
|
|
addOpenGLRunpath $out/bin/mpv
|
2019-08-30 19:54:08 +00:00
|
|
|
'';
|
|
|
|
|
2021-11-03 17:39:01 +00:00
|
|
|
passthru = {
|
|
|
|
inherit
|
|
|
|
# The wrapper consults luaEnv and lua.version
|
|
|
|
luaEnv
|
|
|
|
lua
|
|
|
|
# In the wrapper, we want to reference vapoursynth which has the `python3`
|
|
|
|
# passthru attribute (which has the `sitePrefix` attribute). This way we'll
|
|
|
|
# be sure that in the wrapper we'll use the same python3.sitePrefix used to
|
|
|
|
# build vapoursynth.
|
|
|
|
vapoursynthSupport
|
|
|
|
vapoursynth
|
|
|
|
;
|
2013-12-09 01:25:32 +00:00
|
|
|
};
|
2021-11-11 14:08:25 +00:00
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
homepage = "https://mpv.io";
|
|
|
|
description = "General-purpose media player, fork of MPlayer and mplayer2";
|
|
|
|
longDescription = ''
|
|
|
|
mpv is a free and open-source general-purpose video player, based on the
|
|
|
|
MPlayer and mplayer2 projects, with great improvements above both.
|
|
|
|
'';
|
2023-04-16 20:09:53 +00:00
|
|
|
changelog = "https://github.com/mpv-player/mpv/releases/tag/v${finalAttrs.version}";
|
2021-11-11 14:08:25 +00:00
|
|
|
license = licenses.gpl2Plus;
|
|
|
|
maintainers = with maintainers; [ AndersonTorres fpletz globin ma27 tadeokondrak ];
|
2022-11-12 18:10:13 +00:00
|
|
|
platforms = platforms.unix;
|
2021-11-11 14:08:25 +00:00
|
|
|
};
|
2023-01-28 23:35:42 +00:00
|
|
|
})
|