mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 15:03:28 +00:00
mpv: clean‐ups and Darwin improvements (#350674)
This commit is contained in:
commit
f4f88f9dbc
@ -7,7 +7,6 @@
|
||||
buildPackages,
|
||||
callPackage,
|
||||
config,
|
||||
darwin,
|
||||
docutils,
|
||||
fetchFromGitHub,
|
||||
ffmpeg,
|
||||
@ -15,15 +14,11 @@
|
||||
freetype,
|
||||
lcms2,
|
||||
libGL,
|
||||
libGLU,
|
||||
libX11,
|
||||
libXScrnSaver,
|
||||
libXext,
|
||||
libXinerama,
|
||||
libXpresent,
|
||||
libXrandr,
|
||||
libXv,
|
||||
libXxf86vm,
|
||||
libarchive,
|
||||
libass,
|
||||
libbluray,
|
||||
@ -33,19 +28,17 @@
|
||||
libcdio-paranoia,
|
||||
libdrm,
|
||||
libdvdnav,
|
||||
libiconv,
|
||||
libjack2,
|
||||
libplacebo,
|
||||
libpng,
|
||||
libpthreadstubs,
|
||||
libpulseaudio,
|
||||
libsixel,
|
||||
libtheora,
|
||||
libuchardet,
|
||||
libva,
|
||||
libvdpau,
|
||||
libxkbcommon,
|
||||
lua,
|
||||
makeWrapper,
|
||||
mesa,
|
||||
meson,
|
||||
mujs,
|
||||
@ -58,7 +51,6 @@
|
||||
python3,
|
||||
rubberband,
|
||||
shaderc, # instead of spirv-cross
|
||||
speex,
|
||||
stdenv,
|
||||
swift,
|
||||
testers,
|
||||
@ -68,7 +60,6 @@
|
||||
wayland,
|
||||
wayland-protocols,
|
||||
wayland-scanner,
|
||||
xcbuild,
|
||||
zimg,
|
||||
|
||||
# Boolean
|
||||
@ -81,59 +72,28 @@
|
||||
cmsSupport ? true,
|
||||
drmSupport ? stdenv.hostPlatform.isLinux,
|
||||
dvbinSupport ? stdenv.hostPlatform.isLinux,
|
||||
dvdnavSupport ? stdenv.hostPlatform.isLinux,
|
||||
dvdnavSupport ? true,
|
||||
jackaudioSupport ? false,
|
||||
javascriptSupport ? true,
|
||||
libpngSupport ? true,
|
||||
openalSupport ? true,
|
||||
pipewireSupport ? stdenv.hostPlatform.isLinux,
|
||||
pulseSupport ? config.pulseaudio or stdenv.hostPlatform.isLinux,
|
||||
pipewireSupport ? !stdenv.hostPlatform.isDarwin,
|
||||
pulseSupport ? config.pulseaudio or (!stdenv.hostPlatform.isDarwin),
|
||||
rubberbandSupport ? true,
|
||||
screenSaverSupport ? true,
|
||||
sdl2Support ? !stdenv.hostPlatform.isDarwin,
|
||||
sdl2Support ? false,
|
||||
sixelSupport ? false,
|
||||
speexSupport ? true,
|
||||
swiftSupport ? stdenv.hostPlatform.isDarwin,
|
||||
theoraSupport ? true,
|
||||
vaapiSupport ? x11Support || waylandSupport,
|
||||
vaapiSupport ? !stdenv.hostPlatform.isDarwin && (x11Support || waylandSupport),
|
||||
vapoursynthSupport ? false,
|
||||
vdpauSupport ? true,
|
||||
vulkanSupport ? stdenv.hostPlatform.isLinux,
|
||||
waylandSupport ? stdenv.hostPlatform.isLinux,
|
||||
x11Support ? stdenv.hostPlatform.isLinux,
|
||||
xineramaSupport ? stdenv.hostPlatform.isLinux,
|
||||
xvSupport ? stdenv.hostPlatform.isLinux,
|
||||
vulkanSupport ? true,
|
||||
waylandSupport ? !stdenv.hostPlatform.isDarwin,
|
||||
x11Support ? !stdenv.hostPlatform.isDarwin,
|
||||
zimgSupport ? true,
|
||||
}:
|
||||
|
||||
let
|
||||
inherit (darwin.apple_sdk_11_0.frameworks)
|
||||
AVFoundation
|
||||
Accelerate
|
||||
Cocoa
|
||||
CoreAudio
|
||||
CoreFoundation
|
||||
CoreMedia
|
||||
MediaPlayer
|
||||
VideoToolbox
|
||||
;
|
||||
luaEnv = lua.withPackages (ps: with ps; [ luasocket ]);
|
||||
|
||||
overrideSDK =
|
||||
platform: version:
|
||||
platform // lib.optionalAttrs (platform ? darwinMinVersion) { darwinMinVersion = version; };
|
||||
|
||||
stdenv' =
|
||||
if swiftSupport && stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64 then
|
||||
stdenv.override (old: {
|
||||
buildPlatform = overrideSDK old.buildPlatform "11.0";
|
||||
hostPlatform = overrideSDK old.hostPlatform "11.0";
|
||||
targetPlatform = overrideSDK old.targetPlatform "11.0";
|
||||
})
|
||||
else
|
||||
stdenv;
|
||||
in
|
||||
stdenv'.mkDerivation (finalAttrs: {
|
||||
stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "mpv";
|
||||
version = "0.39.0";
|
||||
|
||||
@ -151,18 +111,13 @@ stdenv'.mkDerivation (finalAttrs: {
|
||||
hash = "sha256-BOGh+QBTO7hrHohh+RqjSF8eHQH8jVBPjG/k4eyFaaM=";
|
||||
};
|
||||
|
||||
patches = [
|
||||
# Fix build with Darwin SDK 11
|
||||
./0001-fix-darwin-build.patch
|
||||
];
|
||||
|
||||
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>')"
|
||||
"conf_data.set_quoted('CONFIGURATION', '<omitted>')"
|
||||
''
|
||||
# A trick to patchShebang everything except mpv_identify.sh
|
||||
''
|
||||
@ -174,30 +129,16 @@ stdenv'.mkDerivation (finalAttrs: {
|
||||
''
|
||||
];
|
||||
|
||||
# Ensure we reference 'lib' (not 'out') of Swift.
|
||||
preConfigure = lib.optionalString swiftSupport ''
|
||||
export SWIFT_LIB_DYNAMIC="${lib.getLib swift.swift}/lib/swift/macosx"
|
||||
'';
|
||||
|
||||
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)
|
||||
# Disable whilst Swift isn't supported
|
||||
(lib.mesonEnable "swift-build" swiftSupport)
|
||||
(lib.mesonEnable "macos-cocoa-cb" swiftSupport)
|
||||
]
|
||||
++ lib.optionals stdenv.hostPlatform.isDarwin [
|
||||
# Toggle explicitly because it fails on darwin
|
||||
(lib.mesonEnable "videotoolbox-pl" vulkanSupport)
|
||||
];
|
||||
mesonFlags = [
|
||||
(lib.mesonOption "default_library" "shared")
|
||||
(lib.mesonBool "libmpv" true)
|
||||
(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)
|
||||
];
|
||||
|
||||
mesonAutoFeatures = "auto";
|
||||
|
||||
@ -211,9 +152,9 @@ stdenv'.mkDerivation (finalAttrs: {
|
||||
]
|
||||
++ lib.optionals stdenv.hostPlatform.isDarwin [
|
||||
buildPackages.darwin.sigtool
|
||||
xcbuild.xcrun
|
||||
swift
|
||||
makeWrapper
|
||||
]
|
||||
++ lib.optionals swiftSupport [ swift ]
|
||||
++ lib.optionals waylandSupport [ wayland-scanner ];
|
||||
|
||||
buildInputs =
|
||||
@ -248,16 +189,12 @@ stdenv'.mkDerivation (finalAttrs: {
|
||||
]
|
||||
++ 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 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 ]
|
||||
@ -274,29 +211,13 @@ stdenv'.mkDerivation (finalAttrs: {
|
||||
++ lib.optionals x11Support [
|
||||
libX11
|
||||
libXext
|
||||
libGLU
|
||||
libGL
|
||||
libXxf86vm
|
||||
libXrandr
|
||||
libXpresent
|
||||
libXScrnSaver
|
||||
]
|
||||
++ lib.optionals xineramaSupport [ libXinerama ]
|
||||
++ lib.optionals xvSupport [ libXv ]
|
||||
++ lib.optionals zimgSupport [ zimg ]
|
||||
++ lib.optionals stdenv.hostPlatform.isLinux [ nv-codec-headers-11 ]
|
||||
++ lib.optionals stdenv.hostPlatform.isDarwin [ libiconv ]
|
||||
++ lib.optionals stdenv.hostPlatform.isDarwin [
|
||||
Accelerate
|
||||
CoreFoundation
|
||||
Cocoa
|
||||
CoreAudio
|
||||
MediaPlayer
|
||||
VideoToolbox
|
||||
]
|
||||
++ lib.optionals (stdenv.hostPlatform.isDarwin && swiftSupport) [
|
||||
AVFoundation
|
||||
CoreMedia
|
||||
];
|
||||
++ lib.optionals stdenv.hostPlatform.isLinux [ nv-codec-headers-11 ];
|
||||
|
||||
postBuild = lib.optionalString stdenv.hostPlatform.isDarwin ''
|
||||
pushd .. # Must be run from the source dir because it uses relative paths
|
||||
@ -325,6 +246,13 @@ stdenv'.mkDerivation (finalAttrs: {
|
||||
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
|
||||
mkdir -p $out/Applications
|
||||
cp -r mpv.app $out/Applications
|
||||
|
||||
# On macOS, many things won’t work properly unless `mpv(1)` is
|
||||
# executed from the app bundle, such as spatial audio with
|
||||
# `--ao=avfoundation`. This wrapper ensures that those features
|
||||
# work reliably and also avoids shipping two copies of the entire
|
||||
# `mpv` executable.
|
||||
makeWrapper $out/Applications/mpv.app/Contents/MacOS/mpv $out/bin/mpv
|
||||
'';
|
||||
|
||||
# Set RUNPATH so that libcuda in /run/opengl-driver(-32)/lib can be found.
|
||||
|
@ -108,6 +108,10 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
"-isystem ${lib.getDev libcxx}/include/c++/v1"
|
||||
"-I${lib.getDev spirv-cross}/include/spirv_cross"
|
||||
"-I${lib.getDev spirv-headers}/include/spirv/unified1"
|
||||
|
||||
# MoltenVK prints a lot of verbose output to the console out of
|
||||
# the box; we adjust this to match Homebrew’s default log level.
|
||||
"-DMVK_CONFIG_LOG_LEVEL=MVK_CONFIG_LOG_LEVEL_NONE"
|
||||
]
|
||||
++ lib.optional enablePrivateAPIUsage "-DMVK_USE_METAL_PRIVATE_API=1"
|
||||
);
|
||||
|
@ -31160,9 +31160,8 @@ with pkgs;
|
||||
libdvdnav = libdvdnav_4_2_1;
|
||||
} // (config.mplayer or {}));
|
||||
|
||||
mpv-unwrapped = darwin.apple_sdk_11_0.callPackage ../applications/video/mpv {
|
||||
mpv-unwrapped = callPackage ../applications/video/mpv {
|
||||
stdenv = if stdenv.hostPlatform.isDarwin then swiftPackages.stdenv else stdenv;
|
||||
inherit lua;
|
||||
};
|
||||
|
||||
# Wrap avoiding rebuild
|
||||
|
Loading…
Reference in New Issue
Block a user