2024-02-29 20:09:43 +00:00
|
|
|
{ lib
|
|
|
|
, config
|
2021-12-06 16:07:01 +00:00
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
2023-03-24 00:07:29 +00:00
|
|
|
, fetchpatch
|
2021-12-06 16:07:01 +00:00
|
|
|
, addOpenGLRunpath
|
2024-01-02 11:29:13 +00:00
|
|
|
, bash
|
2021-12-06 16:07:01 +00:00
|
|
|
, docutils
|
2022-12-17 10:02:37 +00:00
|
|
|
, meson
|
|
|
|
, ninja
|
2021-12-06 16:07:01 +00:00
|
|
|
, pkg-config
|
|
|
|
, python3
|
2023-11-16 04:20:00 +00:00
|
|
|
, ffmpeg
|
2021-12-06 16:07:01 +00:00
|
|
|
, freefont_ttf
|
|
|
|
, freetype
|
|
|
|
, libass
|
|
|
|
, libpthreadstubs
|
2024-01-02 11:29:13 +00:00
|
|
|
, nv-codec-headers-11
|
2021-12-06 16:07:01 +00:00
|
|
|
, lua
|
|
|
|
, libuchardet
|
|
|
|
, libiconv
|
2022-12-17 10:02:37 +00:00
|
|
|
, xcbuild
|
2024-02-29 20:09:43 +00:00
|
|
|
, rcodesign
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
, waylandSupport ? stdenv.isLinux
|
2021-12-06 16:07:01 +00:00
|
|
|
, wayland
|
|
|
|
, wayland-protocols
|
2022-09-09 14:08:57 +00:00
|
|
|
, wayland-scanner
|
2021-12-06 16:07:01 +00:00
|
|
|
, libxkbcommon
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
, x11Support ? stdenv.isLinux
|
2021-12-06 16:07:01 +00:00
|
|
|
, libGLU, libGL
|
|
|
|
, libX11
|
|
|
|
, libXext
|
|
|
|
, libXxf86vm
|
|
|
|
, libXrandr
|
2022-08-21 13:32:41 +00:00
|
|
|
, libXpresent
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
, cddaSupport ? false
|
2021-12-06 16:07:01 +00:00
|
|
|
, libcdio
|
|
|
|
, libcdio-paranoia
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
, vulkanSupport ? stdenv.isLinux
|
2021-12-06 16:07:01 +00:00
|
|
|
, libplacebo
|
2022-11-21 17:40:18 +00:00
|
|
|
, shaderc # instead of spirv-cross
|
2021-12-06 16:07:01 +00:00
|
|
|
, vulkan-headers
|
|
|
|
, vulkan-loader
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
, drmSupport ? stdenv.isLinux
|
2021-12-06 16:07:01 +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-21 17:40:18 +00:00
|
|
|
, dvbinSupport ? stdenv.isLinux
|
2021-12-06 16:07:01 +00:00
|
|
|
, jackaudioSupport ? false, libjack2
|
2022-03-30 09:31:56 +00:00
|
|
|
, javascriptSupport ? true, mujs
|
2021-12-06 16:07:01 +00:00
|
|
|
, libpngSupport ? true, libpng
|
|
|
|
, openalSupport ? true, openalSoft
|
|
|
|
, pulseSupport ? config.pulseaudio or stdenv.isLinux, libpulseaudio
|
2022-11-21 17:40:18 +00:00
|
|
|
, pipewireSupport ? stdenv.isLinux, pipewire
|
2022-09-22 12:36:57 +00:00
|
|
|
, rubberbandSupport ? true, rubberband
|
2021-12-06 16:07:01 +00:00
|
|
|
, screenSaverSupport ? true, libXScrnSaver
|
|
|
|
, sdl2Support ? true, SDL2
|
|
|
|
, sixelSupport ? false, libsixel
|
|
|
|
, speexSupport ? true, speex
|
2023-08-04 22:07:22 +00:00
|
|
|
, swiftSupport ? stdenv.isDarwin, swift
|
2021-12-06 16:07:01 +00:00
|
|
|
, theoraSupport ? true, libtheora
|
2023-05-24 13:37:59 +00:00
|
|
|
, vaapiSupport ? x11Support || waylandSupport, libva
|
2021-12-06 16:07:01 +00:00
|
|
|
, vapoursynthSupport ? false, vapoursynth
|
|
|
|
, vdpauSupport ? true, libvdpau
|
|
|
|
, xineramaSupport ? stdenv.isLinux, libXinerama
|
|
|
|
, xvSupport ? stdenv.isLinux, libXv
|
|
|
|
, zimgSupport ? true, zimg
|
2022-12-17 10:02:37 +00:00
|
|
|
, darwin
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2023-04-12 12:48:02 +00:00
|
|
|
inherit (darwin.apple_sdk_11_0.frameworks)
|
2024-02-29 20:09:43 +00:00
|
|
|
AVFoundation Accelerate Cocoa CoreAudio CoreFoundation CoreMedia
|
|
|
|
MediaPlayer VideoToolbox;
|
2020-04-24 23:36:52 +00:00
|
|
|
luaEnv = lua.withPackages (ps: with ps; [ luasocket ]);
|
2023-08-04 22:07:22 +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: {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "mpv";
|
2024-02-29 20:09:43 +00:00
|
|
|
version = "0.37.0";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-02-29 20:09:43 +00:00
|
|
|
outputs = [ "out" "dev" "doc" "man" ];
|
2021-08-27 14:25:00 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
src = fetchFromGitHub {
|
2021-12-06 16:07:01 +00:00
|
|
|
owner = "mpv-player";
|
|
|
|
repo = "mpv";
|
2023-04-29 16:46:19 +00:00
|
|
|
rev = "v${finalAttrs.version}";
|
2024-02-29 20:09:43 +00:00
|
|
|
hash = "sha256-izAz9Iiam7tJAWIQkmn2cKOfoaog8oPKq4sOUtp1nvU=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2024-02-29 20:09:43 +00:00
|
|
|
patches = [ ./darwin-sigtool-no-deep.patch ];
|
2023-03-24 00:07:29 +00:00
|
|
|
|
2024-02-29 20:09:43 +00:00
|
|
|
postPatch = lib.concatStringsSep "\n" [
|
|
|
|
# Don't reference compile time dependencies or create a build outputs cycle
|
|
|
|
# between out and dev
|
|
|
|
''
|
|
|
|
substituteInPlace meson.build \
|
|
|
|
--replace-fail "conf_data.set_quoted('CONFIGURATION', configuration)" \
|
|
|
|
"conf_data.set_quoted('CONFIGURATION', '<ommited>')"
|
|
|
|
''
|
|
|
|
# A trick to patchShebang everything except mpv_identify.sh
|
|
|
|
''
|
|
|
|
pushd TOOLS
|
|
|
|
mv mpv_identify.sh mpv_identify
|
|
|
|
patchShebangs *.py *.sh
|
|
|
|
mv mpv_identify mpv_identify.sh
|
|
|
|
popd
|
|
|
|
''
|
|
|
|
];
|
2022-12-17 10:02:37 +00:00
|
|
|
|
2024-02-29 20:09:43 +00:00
|
|
|
# Ensure we reference 'lib' (not 'out') of Swift.
|
2023-03-08 16:32:21 +00:00
|
|
|
preConfigure = lib.optionalString swiftSupport ''
|
2024-02-29 20:09:43 +00:00
|
|
|
export SWIFT_LIB_DYNAMIC="${lib.getLib swift.swift}/lib/swift/macosx"
|
2023-03-08 16:32:21 +00:00
|
|
|
'';
|
|
|
|
|
2023-01-11 07:51:40 +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-12-17 10:02:37 +00:00
|
|
|
# Disable whilst Swift isn't supported
|
2023-01-11 07:51:40 +00:00
|
|
|
(lib.mesonEnable "swift-build" swiftSupport)
|
|
|
|
(lib.mesonEnable "macos-cocoa-cb" swiftSupport)
|
2024-02-29 20:09:43 +00:00
|
|
|
] ++ lib.optionals stdenv.isDarwin [
|
|
|
|
# Toggle explicitly because it fails on darwin
|
|
|
|
(lib.mesonEnable "videotoolbox-pl" vulkanSupport)
|
2022-12-17 10:02:37 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
mesonAutoFeatures = "auto";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
nativeBuildInputs = [
|
2021-12-06 16:07:01 +00:00
|
|
|
addOpenGLRunpath
|
2022-11-21 17:40:18 +00:00
|
|
|
docutils # for rst2man
|
2022-12-17 10:02:37 +00:00
|
|
|
meson
|
|
|
|
ninja
|
2021-12-06 16:07:01 +00:00
|
|
|
pkg-config
|
2022-12-17 10:02:37 +00:00
|
|
|
]
|
2024-02-29 20:09:43 +00:00
|
|
|
++ lib.optionals stdenv.isDarwin [ xcbuild.xcrun rcodesign ]
|
2022-12-17 10:02:37 +00:00
|
|
|
++ lib.optionals swiftSupport [ swift ]
|
|
|
|
++ lib.optionals waylandSupport [ wayland-scanner ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
buildInputs = [
|
2024-01-02 11:29:13 +00:00
|
|
|
bash
|
2023-11-16 04:20:00 +00:00
|
|
|
ffmpeg
|
2021-12-06 16:07:01 +00:00
|
|
|
freetype
|
|
|
|
libass
|
2024-02-29 20:09:43 +00:00
|
|
|
libplacebo
|
2021-12-06 16:07:01 +00:00
|
|
|
libpthreadstubs
|
|
|
|
libuchardet
|
|
|
|
luaEnv
|
2024-01-02 11:29:13 +00:00
|
|
|
python3
|
2021-12-06 16:07:01 +00:00
|
|
|
] ++ 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-30 09:31:56 +00:00
|
|
|
++ lib.optionals javascriptSupport [ mujs ]
|
2021-12-06 16:07:01 +00:00
|
|
|
++ lib.optionals libpngSupport [ libpng ]
|
|
|
|
++ lib.optionals openalSupport [ openalSoft ]
|
2022-11-21 17:40:18 +00:00
|
|
|
++ lib.optionals pipewireSupport [ pipewire ]
|
2021-12-06 16:07: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 ]
|
2024-02-29 20:09:43 +00:00
|
|
|
++ lib.optionals vulkanSupport [ shaderc vulkan-headers vulkan-loader ]
|
2021-12-06 16:07:01 +00:00
|
|
|
++ lib.optionals waylandSupport [ wayland wayland-protocols libxkbcommon ]
|
2022-08-21 13:32:41 +00:00
|
|
|
++ lib.optionals x11Support [ libX11 libXext libGLU libGL libXxf86vm libXrandr libXpresent ]
|
2021-12-06 16:07:01 +00:00
|
|
|
++ lib.optionals xineramaSupport [ libXinerama ]
|
|
|
|
++ lib.optionals xvSupport [ libXv ]
|
|
|
|
++ lib.optionals zimgSupport [ zimg ]
|
2024-01-02 11:29:13 +00:00
|
|
|
++ lib.optionals stdenv.isLinux [ nv-codec-headers-11 ]
|
2021-12-06 16:07:01 +00:00
|
|
|
++ lib.optionals stdenv.isDarwin [ libiconv ]
|
2024-02-29 20:09:43 +00:00
|
|
|
++ lib.optionals stdenv.isDarwin [ Accelerate CoreFoundation Cocoa CoreAudio MediaPlayer VideoToolbox ]
|
2023-03-08 16:32:21 +00:00
|
|
|
++ lib.optionals (stdenv.isDarwin && swiftSupport) [ AVFoundation CoreMedia ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
postBuild = lib.optionalString stdenv.isDarwin ''
|
2022-12-17 10:02:37 +00:00
|
|
|
pushd .. # Must be run from the source dir because it uses relative paths
|
2020-04-24 23:36:52 +00:00
|
|
|
python3 TOOLS/osxbundle.py -s build/mpv
|
2022-12-17 10:02:37 +00:00
|
|
|
popd
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
# Use a standard font
|
|
|
|
mkdir -p $out/share/mpv
|
|
|
|
ln -s ${freefont_ttf}/share/fonts/truetype/FreeSans.ttf $out/share/mpv/subfont.ttf
|
|
|
|
|
2024-02-29 20:09:43 +00:00
|
|
|
pushd ../TOOLS
|
|
|
|
cp mpv_identify.sh umpv $out/bin/
|
|
|
|
popd
|
|
|
|
pushd $out/share/applications
|
|
|
|
|
|
|
|
# patch out smb protocol reference, since our ffmpeg can't handle it
|
|
|
|
substituteInPlace mpv.desktop --replace-fail "smb," ""
|
|
|
|
|
|
|
|
sed -e '/Icon=/ ! s|mpv|umpv|g; s|^Exec=.*|Exec=umpv %U|' \
|
|
|
|
mpv.desktop > umpv.desktop
|
|
|
|
printf "NoDisplay=true\n" >> umpv.desktop
|
|
|
|
popd
|
2021-12-06 16:07:01 +00:00
|
|
|
'' + lib.optionalString stdenv.isDarwin ''
|
2020-04-24 23:36:52 +00:00
|
|
|
mkdir -p $out/Applications
|
2022-12-17 10:02:37 +00:00
|
|
|
cp -r mpv.app $out/Applications
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
# Set RUNPATH so that libcuda in /run/opengl-driver(-32)/lib can be found.
|
|
|
|
# See the explanation in addOpenGLRunpath.
|
2021-12-06 16:07:01 +00:00
|
|
|
postFixup = lib.optionalString stdenv.isLinux ''
|
2020-05-29 06:06:01 +00:00
|
|
|
addOpenGLRunpath $out/bin/mpv
|
2024-01-02 11:29:13 +00:00
|
|
|
patchShebangs --update --host $out/bin/umpv $out/bin/mpv_identify.sh
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2021-12-06 16:07: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
|
|
|
|
;
|
|
|
|
};
|
|
|
|
|
2024-02-29 20:09:43 +00:00
|
|
|
meta = {
|
2020-04-24 23:36:52 +00:00
|
|
|
homepage = "https://mpv.io";
|
2021-12-06 16:07:01 +00:00
|
|
|
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-29 16:46:19 +00:00
|
|
|
changelog = "https://github.com/mpv-player/mpv/releases/tag/v${finalAttrs.version}";
|
2024-02-29 20:09:43 +00:00
|
|
|
license = lib.licenses.gpl2Plus;
|
2023-11-16 04:20:00 +00:00
|
|
|
mainProgram = "mpv";
|
2024-02-29 20:09:43 +00:00
|
|
|
maintainers = with lib.maintainers; [
|
|
|
|
AndersonTorres fpletz globin ma27 tadeokondrak
|
|
|
|
];
|
|
|
|
platforms = lib.platforms.unix;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
2023-02-02 18:25:31 +00:00
|
|
|
})
|