mpv: nixfmt

This commit is contained in:
Anderson Torres 2024-05-22 17:37:29 -03:00
parent 238d981213
commit c14b678b5a

View File

@ -1,108 +1,149 @@
{ lib {
, buildPackages lib,
, callPackage SDL2,
, config addOpenGLRunpath,
, stdenv alsa-lib,
, fetchFromGitHub bash,
, addOpenGLRunpath buildPackages,
, bash callPackage,
, docutils config,
, meson darwin,
, ninja docutils,
, pkg-config fetchFromGitHub,
, python3 ffmpeg,
, ffmpeg freefont_ttf,
, freefont_ttf freetype,
, freetype lcms2,
, libass libGL,
, libpthreadstubs libGLU,
, nv-codec-headers-11 libX11,
, lua libXScrnSaver,
, libuchardet libXext,
, libiconv libXinerama,
, xcbuild libXpresent,
libXrandr,
libXv,
libXxf86vm,
libarchive,
libass,
libbluray,
libbs2b,
libcaca,
libcdio,
libcdio-paranoia,
libdrm,
libdvdnav,
libiconv,
libjack2,
libplacebo,
libpng,
libpthreadstubs,
libpulseaudio,
libsixel,
libtheora,
libuchardet,
libva,
libvdpau,
libxkbcommon,
lua,
mesa,
meson,
mujs,
ninja,
nv-codec-headers-11,
openalSoft,
pipewire,
pkg-config,
python3,
rubberband,
shaderc, # instead of spirv-cross
speex,
stdenv,
swift,
vapoursynth,
vulkan-headers,
vulkan-loader,
wayland,
wayland-protocols,
wayland-scanner,
xcbuild,
zimg,
, waylandSupport ? stdenv.isLinux # Boolean
, wayland alsaSupport ? stdenv.isLinux,
, wayland-protocols archiveSupport ? true,
, wayland-scanner bluraySupport ? true,
, libxkbcommon bs2bSupport ? true,
cacaSupport ? true,
, x11Support ? stdenv.isLinux cddaSupport ? false,
, libGLU, libGL cmsSupport ? true,
, libX11 drmSupport ? stdenv.isLinux,
, libXext dvbinSupport ? stdenv.isLinux,
, libXxf86vm dvdnavSupport ? stdenv.isLinux,
, libXrandr jackaudioSupport ? false,
, libXpresent javascriptSupport ? true,
libpngSupport ? true,
, cddaSupport ? false openalSupport ? true,
, libcdio pipewireSupport ? stdenv.isLinux,
, libcdio-paranoia pulseSupport ? config.pulseaudio or stdenv.isLinux,
rubberbandSupport ? true,
, vulkanSupport ? stdenv.isLinux screenSaverSupport ? true,
, libplacebo sdl2Support ? true,
, shaderc # instead of spirv-cross sixelSupport ? false,
, vulkan-headers speexSupport ? true,
, vulkan-loader swiftSupport ? stdenv.isDarwin,
theoraSupport ? true,
, drmSupport ? stdenv.isLinux vaapiSupport ? x11Support || waylandSupport,
, libdrm vapoursynthSupport ? false,
, mesa vdpauSupport ? true,
vulkanSupport ? stdenv.isLinux,
, alsaSupport ? stdenv.isLinux, alsa-lib waylandSupport ? stdenv.isLinux,
, archiveSupport ? true, libarchive x11Support ? stdenv.isLinux,
, bluraySupport ? true, libbluray xineramaSupport ? stdenv.isLinux,
, bs2bSupport ? true, libbs2b xvSupport ? stdenv.isLinux,
, cacaSupport ? true, libcaca zimgSupport ? true,
, cmsSupport ? true, lcms2
, dvdnavSupport ? stdenv.isLinux, libdvdnav
, dvbinSupport ? stdenv.isLinux
, jackaudioSupport ? false, libjack2
, javascriptSupport ? true, mujs
, libpngSupport ? true, libpng
, openalSupport ? true, openalSoft
, pulseSupport ? config.pulseaudio or stdenv.isLinux, libpulseaudio
, pipewireSupport ? stdenv.isLinux, pipewire
, rubberbandSupport ? true, rubberband
, screenSaverSupport ? true, libXScrnSaver
, sdl2Support ? true, SDL2
, sixelSupport ? false, libsixel
, speexSupport ? true, speex
, swiftSupport ? stdenv.isDarwin, swift
, theoraSupport ? true, libtheora
, vaapiSupport ? x11Support || waylandSupport, libva
, vapoursynthSupport ? false, vapoursynth
, vdpauSupport ? true, libvdpau
, xineramaSupport ? stdenv.isLinux, libXinerama
, xvSupport ? stdenv.isLinux, libXv
, zimgSupport ? true, zimg
, darwin
}: }:
let let
inherit (darwin.apple_sdk_11_0.frameworks) inherit (darwin.apple_sdk_11_0.frameworks)
AVFoundation Accelerate Cocoa CoreAudio CoreFoundation CoreMedia AVFoundation
MediaPlayer VideoToolbox; Accelerate
Cocoa
CoreAudio
CoreFoundation
CoreMedia
MediaPlayer
VideoToolbox
;
luaEnv = lua.withPackages (ps: with ps; [ luasocket ]); luaEnv = lua.withPackages (ps: with ps; [ luasocket ]);
overrideSDK = platform: version: overrideSDK =
platform // lib.optionalAttrs (platform ? darwinMinVersion) { platform: version:
platform
// lib.optionalAttrs (platform ? darwinMinVersion) {
darwinMinVersion = version; darwinMinVersion = version;
}; };
stdenv' = if swiftSupport && stdenv.isDarwin && stdenv.isx86_64 stdenv' =
then stdenv.override (old: { if swiftSupport && stdenv.isDarwin && stdenv.isx86_64 then
buildPlatform = overrideSDK old.buildPlatform "10.15"; stdenv.override (old: {
hostPlatform = overrideSDK old.hostPlatform "10.15"; buildPlatform = overrideSDK old.buildPlatform "10.15";
targetPlatform = overrideSDK old.targetPlatform "10.15"; hostPlatform = overrideSDK old.hostPlatform "10.15";
}) targetPlatform = overrideSDK old.targetPlatform "10.15";
else stdenv; })
in stdenv'.mkDerivation (finalAttrs: { else
stdenv;
in
stdenv'.mkDerivation (finalAttrs: {
pname = "mpv"; pname = "mpv";
version = "0.38.0"; version = "0.38.0";
outputs = [ "out" "dev" "doc" "man" ]; outputs = [
"out"
"dev"
"doc"
"man"
];
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "mpv-player"; owner = "mpv-player";
@ -115,17 +156,17 @@ in stdenv'.mkDerivation (finalAttrs: {
# Don't reference compile time dependencies or create a build outputs cycle # Don't reference compile time dependencies or create a build outputs cycle
# between out and dev # between out and dev
'' ''
substituteInPlace meson.build \ substituteInPlace meson.build \
--replace-fail "conf_data.set_quoted('CONFIGURATION', configuration)" \ --replace-fail "conf_data.set_quoted('CONFIGURATION', configuration)" \
"conf_data.set_quoted('CONFIGURATION', '<ommited>')" "conf_data.set_quoted('CONFIGURATION', '<ommited>')"
'' ''
# A trick to patchShebang everything except mpv_identify.sh # A trick to patchShebang everything except mpv_identify.sh
'' ''
pushd TOOLS pushd TOOLS
mv mpv_identify.sh mpv_identify mv mpv_identify.sh mpv_identify
patchShebangs *.py *.sh patchShebangs *.py *.sh
mv mpv_identify mpv_identify.sh mv mpv_identify mpv_identify.sh
popd popd
'' ''
]; ];
@ -134,81 +175,124 @@ in stdenv'.mkDerivation (finalAttrs: {
export SWIFT_LIB_DYNAMIC="${lib.getLib swift.swift}/lib/swift/macosx" export SWIFT_LIB_DYNAMIC="${lib.getLib swift.swift}/lib/swift/macosx"
''; '';
mesonFlags = [ mesonFlags =
(lib.mesonOption "default_library" "shared") [
(lib.mesonBool "libmpv" true) (lib.mesonOption "default_library" "shared")
(lib.mesonEnable "libarchive" archiveSupport) (lib.mesonBool "libmpv" true)
(lib.mesonEnable "manpage-build" true) (lib.mesonEnable "libarchive" archiveSupport)
(lib.mesonEnable "cdda" cddaSupport) (lib.mesonEnable "manpage-build" true)
(lib.mesonEnable "dvbin" dvbinSupport) (lib.mesonEnable "cdda" cddaSupport)
(lib.mesonEnable "dvdnav" dvdnavSupport) (lib.mesonEnable "dvbin" dvbinSupport)
(lib.mesonEnable "openal" openalSupport) (lib.mesonEnable "dvdnav" dvdnavSupport)
(lib.mesonEnable "sdl2" sdl2Support) (lib.mesonEnable "openal" openalSupport)
# Disable whilst Swift isn't supported (lib.mesonEnable "sdl2" sdl2Support)
(lib.mesonEnable "swift-build" swiftSupport) # Disable whilst Swift isn't supported
(lib.mesonEnable "macos-cocoa-cb" swiftSupport) (lib.mesonEnable "swift-build" swiftSupport)
] ++ lib.optionals stdenv.isDarwin [ (lib.mesonEnable "macos-cocoa-cb" swiftSupport)
# Toggle explicitly because it fails on darwin ]
(lib.mesonEnable "videotoolbox-pl" vulkanSupport) ++ lib.optionals stdenv.isDarwin [
]; # Toggle explicitly because it fails on darwin
(lib.mesonEnable "videotoolbox-pl" vulkanSupport)
];
mesonAutoFeatures = "auto"; mesonAutoFeatures = "auto";
nativeBuildInputs = [ nativeBuildInputs =
addOpenGLRunpath [
docutils # for rst2man addOpenGLRunpath
meson docutils # for rst2man
ninja meson
pkg-config ninja
] pkg-config
++ lib.optionals stdenv.isDarwin [ buildPackages.darwin.sigtool xcbuild.xcrun ] ]
++ lib.optionals swiftSupport [ swift ] ++ lib.optionals stdenv.isDarwin [
++ lib.optionals waylandSupport [ wayland-scanner ]; buildPackages.darwin.sigtool
xcbuild.xcrun
]
++ lib.optionals swiftSupport [ swift ]
++ lib.optionals waylandSupport [ wayland-scanner ];
buildInputs = [ buildInputs =
bash [
ffmpeg bash
freetype ffmpeg
libass freetype
libplacebo libass
libpthreadstubs libplacebo
libuchardet libpthreadstubs
luaEnv libuchardet
python3 luaEnv
] ++ lib.optionals alsaSupport [ alsa-lib ] python3
++ lib.optionals archiveSupport [ libarchive ] ]
++ lib.optionals bluraySupport [ libbluray ] ++ lib.optionals alsaSupport [ alsa-lib ]
++ lib.optionals bs2bSupport [ libbs2b ] ++ lib.optionals archiveSupport [ libarchive ]
++ lib.optionals cacaSupport [ libcaca ] ++ lib.optionals bluraySupport [ libbluray ]
++ lib.optionals cddaSupport [ libcdio libcdio-paranoia ] ++ lib.optionals bs2bSupport [ libbs2b ]
++ lib.optionals cmsSupport [ lcms2 ] ++ lib.optionals cacaSupport [ libcaca ]
++ lib.optionals drmSupport [ libdrm mesa ] ++ lib.optionals cddaSupport [
++ lib.optionals dvdnavSupport [ libdvdnav libdvdnav.libdvdread ] libcdio
++ lib.optionals jackaudioSupport [ libjack2 ] libcdio-paranoia
++ lib.optionals javascriptSupport [ mujs ] ]
++ lib.optionals libpngSupport [ libpng ] ++ lib.optionals cmsSupport [ lcms2 ]
++ lib.optionals openalSupport [ openalSoft ] ++ lib.optionals drmSupport [
++ lib.optionals pipewireSupport [ pipewire ] libdrm
++ lib.optionals pulseSupport [ libpulseaudio ] mesa
++ lib.optionals rubberbandSupport [ rubberband ] ]
++ lib.optionals dvdnavSupport [
libdvdnav
libdvdnav.libdvdread
]
++ lib.optionals jackaudioSupport [ libjack2 ]
++ lib.optionals javascriptSupport [ mujs ]
++ lib.optionals libpngSupport [ libpng ]
++ lib.optionals openalSupport [ openalSoft ]
++ lib.optionals pipewireSupport [ pipewire ]
++ lib.optionals pulseSupport [ libpulseaudio ]
++ lib.optionals rubberbandSupport [ rubberband ]
++ lib.optionals screenSaverSupport [ libXScrnSaver ] ++ lib.optionals screenSaverSupport [ libXScrnSaver ]
++ lib.optionals sdl2Support [ SDL2 ] ++ lib.optionals sdl2Support [ SDL2 ]
++ lib.optionals sixelSupport [ libsixel ] ++ lib.optionals sixelSupport [ libsixel ]
++ lib.optionals speexSupport [ speex ] ++ lib.optionals speexSupport [ speex ]
++ lib.optionals theoraSupport [ libtheora ] ++ lib.optionals theoraSupport [ libtheora ]
++ lib.optionals vaapiSupport [ libva ] ++ lib.optionals vaapiSupport [ libva ]
++ lib.optionals vapoursynthSupport [ vapoursynth ] ++ lib.optionals vapoursynthSupport [ vapoursynth ]
++ lib.optionals vdpauSupport [ libvdpau ] ++ lib.optionals vdpauSupport [ libvdpau ]
++ lib.optionals vulkanSupport [ shaderc vulkan-headers vulkan-loader ] ++ lib.optionals vulkanSupport [
++ lib.optionals waylandSupport [ wayland wayland-protocols libxkbcommon ] shaderc
++ lib.optionals x11Support [ libX11 libXext libGLU libGL libXxf86vm libXrandr libXpresent ] vulkan-headers
++ lib.optionals xineramaSupport [ libXinerama ] vulkan-loader
++ lib.optionals xvSupport [ libXv ] ]
++ lib.optionals zimgSupport [ zimg ] ++ lib.optionals waylandSupport [
++ lib.optionals stdenv.isLinux [ nv-codec-headers-11 ] wayland
++ lib.optionals stdenv.isDarwin [ libiconv ] wayland-protocols
++ lib.optionals stdenv.isDarwin [ Accelerate CoreFoundation Cocoa CoreAudio MediaPlayer VideoToolbox ] libxkbcommon
++ lib.optionals (stdenv.isDarwin && swiftSupport) [ AVFoundation CoreMedia ]; ]
++ lib.optionals x11Support [
libX11
libXext
libGLU
libGL
libXxf86vm
libXrandr
libXpresent
]
++ lib.optionals xineramaSupport [ libXinerama ]
++ lib.optionals xvSupport [ libXv ]
++ lib.optionals zimgSupport [ zimg ]
++ lib.optionals stdenv.isLinux [ nv-codec-headers-11 ]
++ lib.optionals stdenv.isDarwin [ libiconv ]
++ lib.optionals stdenv.isDarwin [
Accelerate
CoreFoundation
Cocoa
CoreAudio
MediaPlayer
VideoToolbox
]
++ lib.optionals (stdenv.isDarwin && swiftSupport) [
AVFoundation
CoreMedia
];
postBuild = lib.optionalString stdenv.isDarwin '' postBuild = lib.optionalString stdenv.isDarwin ''
pushd .. # Must be run from the source dir because it uses relative paths pushd .. # Must be run from the source dir because it uses relative paths
@ -216,27 +300,29 @@ in stdenv'.mkDerivation (finalAttrs: {
popd popd
''; '';
postInstall = '' postInstall =
# Use a standard font ''
mkdir -p $out/share/mpv # Use a standard font
ln -s ${freefont_ttf}/share/fonts/truetype/FreeSans.ttf $out/share/mpv/subfont.ttf mkdir -p $out/share/mpv
ln -s ${freefont_ttf}/share/fonts/truetype/FreeSans.ttf $out/share/mpv/subfont.ttf
pushd ../TOOLS pushd ../TOOLS
cp mpv_identify.sh umpv $out/bin/ cp mpv_identify.sh umpv $out/bin/
popd popd
pushd $out/share/applications pushd $out/share/applications
# patch out smb protocol reference, since our ffmpeg can't handle it # patch out smb protocol reference, since our ffmpeg can't handle it
substituteInPlace mpv.desktop --replace-fail "smb," "" substituteInPlace mpv.desktop --replace-fail "smb," ""
sed -e '/Icon=/ ! s|mpv|umpv|g; s|^Exec=.*|Exec=umpv %U|' \ sed -e '/Icon=/ ! s|mpv|umpv|g; s|^Exec=.*|Exec=umpv %U|' \
mpv.desktop > umpv.desktop mpv.desktop > umpv.desktop
printf "NoDisplay=true\n" >> umpv.desktop printf "NoDisplay=true\n" >> umpv.desktop
popd popd
'' + lib.optionalString stdenv.isDarwin '' ''
mkdir -p $out/Applications + lib.optionalString stdenv.isDarwin ''
cp -r mpv.app $out/Applications mkdir -p $out/Applications
''; cp -r mpv.app $out/Applications
'';
# Set RUNPATH so that libcuda in /run/opengl-driver(-32)/lib can be found. # Set RUNPATH so that libcuda in /run/opengl-driver(-32)/lib can be found.
# See the explanation in addOpenGLRunpath. # See the explanation in addOpenGLRunpath.
@ -247,16 +333,16 @@ in stdenv'.mkDerivation (finalAttrs: {
passthru = { passthru = {
inherit inherit
# The wrapper consults luaEnv and lua.version # The wrapper consults luaEnv and lua.version
luaEnv luaEnv
lua lua
# In the wrapper, we want to reference vapoursynth which has the `python3` # In the wrapper, we want to reference vapoursynth which has the `python3`
# passthru attribute (which has the `sitePrefix` attribute). This way we'll # 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 # be sure that in the wrapper we'll use the same python3.sitePrefix used to
# build vapoursynth. # build vapoursynth.
vapoursynthSupport vapoursynthSupport
vapoursynth vapoursynth
; ;
wrapper = callPackage ./wrapper.nix { }; wrapper = callPackage ./wrapper.nix { };
scripts = callPackage ./scripts { }; scripts = callPackage ./scripts { };
@ -274,7 +360,11 @@ in stdenv'.mkDerivation (finalAttrs: {
license = lib.licenses.gpl2Plus; license = lib.licenses.gpl2Plus;
mainProgram = "mpv"; mainProgram = "mpv";
maintainers = with lib.maintainers; [ maintainers = with lib.maintainers; [
AndersonTorres fpletz globin ma27 tadeokondrak AndersonTorres
fpletz
globin
ma27
tadeokondrak
]; ];
platforms = lib.platforms.unix; platforms = lib.platforms.unix;
}; };