From af97e98efdb895a7db003e7c4d5928ea5d46d6ab Mon Sep 17 00:00:00 2001 From: Anderson Torres Date: Tue, 28 Nov 2023 13:22:55 -0300 Subject: [PATCH 1/6] mpv: 0.36.0 -> 0.37.0 And some refactors: - Remove dev output (cycle detected in build of in the references of output 'dev' from output 'out') - Env vars inside env - Remove nested with --- pkgs/applications/video/mpv/default.nix | 62 +++++++++++++------------ pkgs/top-level/all-packages.nix | 2 +- 2 files changed, 33 insertions(+), 31 deletions(-) diff --git a/pkgs/applications/video/mpv/default.nix b/pkgs/applications/video/mpv/default.nix index 3fc3b4eb1a8b8..739d7511b5050 100644 --- a/pkgs/applications/video/mpv/default.nix +++ b/pkgs/applications/video/mpv/default.nix @@ -1,5 +1,5 @@ -{ config -, lib +{ lib +, config , stdenv , fetchFromGitHub , fetchpatch @@ -82,7 +82,8 @@ let inherit (darwin.apple_sdk_11_0.frameworks) - AVFoundation CoreFoundation CoreMedia Cocoa CoreAudio MediaPlayer Accelerate; + AVFoundation Accelerate Cocoa CoreAudio CoreFoundation CoreMedia + MediaPlayer; luaEnv = lua.withPackages (ps: with ps; [ luasocket ]); overrideSDK = platform: version: @@ -99,36 +100,31 @@ let else stdenv; in stdenv'.mkDerivation (finalAttrs: { pname = "mpv"; - version = "0.36.0"; + version = "0.37.0"; - outputs = [ "out" "dev" "man" ]; + outputs = [ "out" "doc" "man" ]; src = fetchFromGitHub { owner = "mpv-player"; repo = "mpv"; rev = "v${finalAttrs.version}"; - hash = "sha256-82moFbWvfc1awXih0d0D+dHqYbIoGNZ77RmafQ80IOY="; + hash = "sha256-izAz9Iiam7tJAWIQkmn2cKOfoaog8oPKq4sOUtp1nvU="; }; - patches = [ - # Revert "meson: use the new build_options method" to avoid a - # cycle between the out and dev outputs. - (fetchpatch { - url = "https://github.com/mpv-player/mpv/commit/3c1686488b48bd2760e9b19f42e7d3be1363d00a.patch"; - hash = "sha256-eYXfX8Y08q4Bl41VHBpwbxYRMZgm/iziXeK6AOp8O6I="; - revert = true; - }) - ]; + env.NIX_LDFLAGS = lib.optionalString x11Support "-lX11 -lXext "; + # A trick to patchShebang everything except mpv_identify.sh postPatch = '' - patchShebangs version.* ./TOOLS/ + pushd TOOLS + mv mpv_identify.sh mpv_identify + patchShebangs *.py *.sh + mv mpv_identify mpv_identify.sh + popd ''; - NIX_LDFLAGS = lib.optionalString x11Support "-lX11 -lXext "; - + # Ensure we reference 'lib' (not 'out') of Swift. preConfigure = lib.optionalString swiftSupport '' - # Ensure we reference 'lib' (not 'out') of Swift. - export SWIFT_LIB_DYNAMIC=${lib.getLib swift.swift}/lib/swift/macosx + export SWIFT_LIB_DYNAMIC="${lib.getLib swift.swift}/lib/swift/macosx" ''; mesonFlags = [ @@ -206,7 +202,8 @@ in stdenv'.mkDerivation (finalAttrs: { postBuild = lib.optionalString stdenv.isDarwin '' pushd .. # Must be run from the source dir because it uses relative paths python3 TOOLS/osxbundle.py -s build/mpv - # Swap binary and bundle symlink to sign bundle executable as symlinks cannot be signed + # Swap binary and bundle symlink to sign bundle executable as symlinks + # cannot be signed rm build/mpv.app/Contents/MacOS/mpv-bundle mv build/mpv.app/Contents/MacOS/mpv build/mpv.app/Contents/MacOS/mpv-bundle ln -s mpv-bundle build/mpv.app/Contents/MacOS/mpv @@ -219,11 +216,14 @@ in stdenv'.mkDerivation (finalAttrs: { mkdir -p $out/share/mpv ln -s ${freefont_ttf}/share/fonts/truetype/FreeSans.ttf $out/share/mpv/subfont.ttf - cp ../TOOLS/mpv_identify.sh $out/bin - cp ../TOOLS/umpv $out/bin - cp $out/share/applications/mpv.desktop $out/share/applications/umpv.desktop - sed -i '/Icon=/ ! s/mpv/umpv/g; s/^Exec=.*/Exec=umpv %U/' $out/share/applications/umpv.desktop - printf "NoDisplay=true\n" >> $out/share/applications/umpv.desktop + pushd ../TOOLS + cp mpv_identify.sh umpv $out/bin/ + popd + pushd $out/share/applications + sed -e '/Icon=/ ! s|mpv|umpv|g; s|^Exec=.*|Exec=umpv %U|' \ + mpv.desktop > umpv.desktop + printf "NoDisplay=true\n" >> umpv.desktop + popd '' + lib.optionalString stdenv.isDarwin '' mkdir -p $out/Applications cp -r mpv.app $out/Applications @@ -250,7 +250,7 @@ in stdenv'.mkDerivation (finalAttrs: { ; }; - meta = with lib; { + meta = { homepage = "https://mpv.io"; description = "General-purpose media player, fork of MPlayer and mplayer2"; longDescription = '' @@ -258,9 +258,11 @@ in stdenv'.mkDerivation (finalAttrs: { MPlayer and mplayer2 projects, with great improvements above both. ''; changelog = "https://github.com/mpv-player/mpv/releases/tag/v${finalAttrs.version}"; - license = licenses.gpl2Plus; + license = lib.licenses.gpl2Plus; mainProgram = "mpv"; - maintainers = with maintainers; [ AndersonTorres fpletz globin ma27 tadeokondrak ]; - platforms = platforms.unix; + maintainers = with lib.maintainers; [ + AndersonTorres fpletz globin ma27 tadeokondrak + ]; + platforms = lib.platforms.unix; }; }) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 39a0283ea49b0..d723c44520da2 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -33765,7 +33765,7 @@ with pkgs; mpv-unwrapped = darwin.apple_sdk_11_0.callPackage ../applications/video/mpv { stdenv = if stdenv.isDarwin then swiftPackages.stdenv else stdenv; inherit lua; - inherit (darwin) sigtool; + inherit (darwin) sigtool; # otherwise it breaks splicing... }; shaka-packager = callPackage ../applications/video/shaka-packager { }; From 3d1ef6d39a14efd65b6b43cc1b93f0cb633b83b0 Mon Sep 17 00:00:00 2001 From: Anderson Torres Date: Mon, 29 Jan 2024 22:47:34 -0300 Subject: [PATCH 2/6] mpv: extra dependencies for Darwin Namely, libplacebo (since it is now unconditional) and VideoToolbox. Co-authored-by: Franz Pletz Co-authored-by: David Knaack --- pkgs/applications/video/mpv/default.nix | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pkgs/applications/video/mpv/default.nix b/pkgs/applications/video/mpv/default.nix index 739d7511b5050..e0b53747485d5 100644 --- a/pkgs/applications/video/mpv/default.nix +++ b/pkgs/applications/video/mpv/default.nix @@ -83,7 +83,7 @@ let inherit (darwin.apple_sdk_11_0.frameworks) AVFoundation Accelerate Cocoa CoreAudio CoreFoundation CoreMedia - MediaPlayer; + MediaPlayer VideoToolbox; luaEnv = lua.withPackages (ps: with ps; [ luasocket ]); overrideSDK = platform: version: @@ -140,6 +140,9 @@ in stdenv'.mkDerivation (finalAttrs: { # Disable whilst Swift isn't supported (lib.mesonEnable "swift-build" swiftSupport) (lib.mesonEnable "macos-cocoa-cb" swiftSupport) + ] ++ lib.optionals stdenv.isDarwin [ + # Toggle explicitly because it fails on darwin + (lib.mesonEnable "videotoolbox-pl" vulkanSupport) ]; mesonAutoFeatures = "auto"; @@ -160,6 +163,7 @@ in stdenv'.mkDerivation (finalAttrs: { ffmpeg freetype libass + libplacebo libpthreadstubs libuchardet luaEnv @@ -188,7 +192,7 @@ in stdenv'.mkDerivation (finalAttrs: { ++ lib.optionals vaapiSupport [ libva ] ++ lib.optionals vapoursynthSupport [ vapoursynth ] ++ lib.optionals vdpauSupport [ libvdpau ] - ++ lib.optionals vulkanSupport [ libplacebo shaderc vulkan-headers vulkan-loader ] + ++ lib.optionals vulkanSupport [ shaderc vulkan-headers vulkan-loader ] ++ lib.optionals waylandSupport [ wayland wayland-protocols libxkbcommon ] ++ lib.optionals x11Support [ libX11 libXext libGLU libGL libXxf86vm libXrandr libXpresent ] ++ lib.optionals xineramaSupport [ libXinerama ] @@ -196,7 +200,7 @@ in stdenv'.mkDerivation (finalAttrs: { ++ lib.optionals zimgSupport [ zimg ] ++ lib.optionals stdenv.isLinux [ nv-codec-headers-11 ] ++ lib.optionals stdenv.isDarwin [ libiconv ] - ++ lib.optionals stdenv.isDarwin [ CoreFoundation Cocoa CoreAudio MediaPlayer Accelerate ] + ++ lib.optionals stdenv.isDarwin [ Accelerate CoreFoundation Cocoa CoreAudio MediaPlayer VideoToolbox ] ++ lib.optionals (stdenv.isDarwin && swiftSupport) [ AVFoundation CoreMedia ]; postBuild = lib.optionalString stdenv.isDarwin '' From ce6ca5eb065dfe98789b6cd698788f02328efc67 Mon Sep 17 00:00:00 2001 From: David Knaack Date: Tue, 30 Jan 2024 13:28:38 +0100 Subject: [PATCH 3/6] mpv: fix app-bundling --- .../video/mpv/darwin-sigtool-no-deep.patch | 13 +++++++++++++ pkgs/applications/video/mpv/default.nix | 8 ++------ pkgs/applications/video/mpv/wrapper.nix | 2 +- 3 files changed, 16 insertions(+), 7 deletions(-) create mode 100644 pkgs/applications/video/mpv/darwin-sigtool-no-deep.patch diff --git a/pkgs/applications/video/mpv/darwin-sigtool-no-deep.patch b/pkgs/applications/video/mpv/darwin-sigtool-no-deep.patch new file mode 100644 index 0000000000000..35ca32653a36f --- /dev/null +++ b/pkgs/applications/video/mpv/darwin-sigtool-no-deep.patch @@ -0,0 +1,13 @@ +diff --git a/TOOLS/osxbundle.py b/TOOLS/osxbundle.py +index 98699e478b..d02ecf610e 100755 +--- a/TOOLS/osxbundle.py ++++ b/TOOLS/osxbundle.py +@@ -39,7 +39,7 @@ def apply_plist_template(plist_file, version): + print(line.rstrip().replace('${VERSION}', version)) + + def sign_bundle(binary_name): +- sh('codesign --force --deep -s - ' + bundle_path(binary_name)) ++ sh('codesign --force -s - ' + bundle_path(binary_name)) + + def bundle_version(): + if os.path.exists('VERSION'): diff --git a/pkgs/applications/video/mpv/default.nix b/pkgs/applications/video/mpv/default.nix index e0b53747485d5..88c13cf1c105e 100644 --- a/pkgs/applications/video/mpv/default.nix +++ b/pkgs/applications/video/mpv/default.nix @@ -113,6 +113,8 @@ in stdenv'.mkDerivation (finalAttrs: { env.NIX_LDFLAGS = lib.optionalString x11Support "-lX11 -lXext "; + patches = [ ./darwin-sigtool-no-deep.patch ]; + # A trick to patchShebang everything except mpv_identify.sh postPatch = '' pushd TOOLS @@ -206,12 +208,6 @@ in stdenv'.mkDerivation (finalAttrs: { postBuild = lib.optionalString stdenv.isDarwin '' pushd .. # Must be run from the source dir because it uses relative paths python3 TOOLS/osxbundle.py -s build/mpv - # Swap binary and bundle symlink to sign bundle executable as symlinks - # cannot be signed - rm build/mpv.app/Contents/MacOS/mpv-bundle - mv build/mpv.app/Contents/MacOS/mpv build/mpv.app/Contents/MacOS/mpv-bundle - ln -s mpv-bundle build/mpv.app/Contents/MacOS/mpv - codesign --force --sign - build/mpv.app/Contents/MacOS/mpv-bundle popd ''; diff --git a/pkgs/applications/video/mpv/wrapper.nix b/pkgs/applications/video/mpv/wrapper.nix index a86c9671a4813..b427318121ef0 100644 --- a/pkgs/applications/video/mpv/wrapper.nix +++ b/pkgs/applications/video/mpv/wrapper.nix @@ -97,7 +97,7 @@ let '' + lib.optionalString stdenv.isDarwin '' # wrapProgram can't operate on symlinks rm "$out/Applications/mpv.app/Contents/MacOS/mpv" - makeWrapper "${mpv}/Applications/mpv.app/Contents/MacOS/mpv-bundle" "$out/Applications/mpv.app/Contents/MacOS/mpv" ${mostMakeWrapperArgs} + makeWrapper "${mpv}/Applications/mpv.app/Contents/MacOS/mpv" "$out/Applications/mpv.app/Contents/MacOS/mpv" ${mostMakeWrapperArgs} ''; meta = { From 7e96adf643f17b7a08d6febdf12b4be484305b82 Mon Sep 17 00:00:00 2001 From: Anderson Torres Date: Fri, 2 Feb 2024 10:53:07 -0300 Subject: [PATCH 4/6] mpv: use rcodesign instead of darwin.codesign Co-authored-by: Randy Eckenrode --- pkgs/applications/video/mpv/darwin-sigtool-no-deep.patch | 2 +- pkgs/applications/video/mpv/default.nix | 4 ++-- pkgs/top-level/all-packages.nix | 1 - 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/pkgs/applications/video/mpv/darwin-sigtool-no-deep.patch b/pkgs/applications/video/mpv/darwin-sigtool-no-deep.patch index 35ca32653a36f..74ab97db4e540 100644 --- a/pkgs/applications/video/mpv/darwin-sigtool-no-deep.patch +++ b/pkgs/applications/video/mpv/darwin-sigtool-no-deep.patch @@ -7,7 +7,7 @@ index 98699e478b..d02ecf610e 100755 def sign_bundle(binary_name): - sh('codesign --force --deep -s - ' + bundle_path(binary_name)) -+ sh('codesign --force -s - ' + bundle_path(binary_name)) ++ sh('rcodesign sign ' + bundle_path(binary_name)) def bundle_version(): if os.path.exists('VERSION'): diff --git a/pkgs/applications/video/mpv/default.nix b/pkgs/applications/video/mpv/default.nix index 88c13cf1c105e..02c3aa2ad17a4 100644 --- a/pkgs/applications/video/mpv/default.nix +++ b/pkgs/applications/video/mpv/default.nix @@ -20,7 +20,7 @@ , libuchardet , libiconv , xcbuild -, sigtool +, rcodesign , waylandSupport ? stdenv.isLinux , wayland @@ -156,7 +156,7 @@ in stdenv'.mkDerivation (finalAttrs: { ninja pkg-config ] - ++ lib.optionals stdenv.isDarwin [ xcbuild.xcrun sigtool ] + ++ lib.optionals stdenv.isDarwin [ xcbuild.xcrun rcodesign ] ++ lib.optionals swiftSupport [ swift ] ++ lib.optionals waylandSupport [ wayland-scanner ]; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index d723c44520da2..bf71f07f15a9d 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -33765,7 +33765,6 @@ with pkgs; mpv-unwrapped = darwin.apple_sdk_11_0.callPackage ../applications/video/mpv { stdenv = if stdenv.isDarwin then swiftPackages.stdenv else stdenv; inherit lua; - inherit (darwin) sigtool; # otherwise it breaks splicing... }; shaka-packager = callPackage ../applications/video/shaka-packager { }; From a88842e1079dfe6bde414894a35278f9b102be97 Mon Sep 17 00:00:00 2001 From: Anderson Torres Date: Fri, 9 Feb 2024 21:27:30 -0300 Subject: [PATCH 5/6] mpv: split dev output via patching MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Sandro Jäckel --- pkgs/applications/video/mpv/default.nix | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/pkgs/applications/video/mpv/default.nix b/pkgs/applications/video/mpv/default.nix index 02c3aa2ad17a4..88c54380346eb 100644 --- a/pkgs/applications/video/mpv/default.nix +++ b/pkgs/applications/video/mpv/default.nix @@ -102,7 +102,7 @@ in stdenv'.mkDerivation (finalAttrs: { pname = "mpv"; version = "0.37.0"; - outputs = [ "out" "doc" "man" ]; + outputs = [ "out" "dev" "doc" "man" ]; src = fetchFromGitHub { owner = "mpv-player"; @@ -111,18 +111,27 @@ in stdenv'.mkDerivation (finalAttrs: { hash = "sha256-izAz9Iiam7tJAWIQkmn2cKOfoaog8oPKq4sOUtp1nvU="; }; - env.NIX_LDFLAGS = lib.optionalString x11Support "-lX11 -lXext "; - patches = [ ./darwin-sigtool-no-deep.patch ]; - # A trick to patchShebang everything except mpv_identify.sh - postPatch = '' + 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', '')" + '' + # 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 - ''; + '' + ]; + + env.NIX_LDFLAGS = lib.optionalString x11Support "-lX11 -lXext "; # Ensure we reference 'lib' (not 'out') of Swift. preConfigure = lib.optionalString swiftSupport '' From 390daad68ad8a469b8350c75ff14815d0d061dc7 Mon Sep 17 00:00:00 2001 From: Anderson Torres Date: Fri, 9 Feb 2024 21:29:47 -0300 Subject: [PATCH 6/6] mpv: remove env.NIX_LDFLAGS setting --- pkgs/applications/video/mpv/default.nix | 2 -- 1 file changed, 2 deletions(-) diff --git a/pkgs/applications/video/mpv/default.nix b/pkgs/applications/video/mpv/default.nix index 88c54380346eb..01a875d667b7a 100644 --- a/pkgs/applications/video/mpv/default.nix +++ b/pkgs/applications/video/mpv/default.nix @@ -131,8 +131,6 @@ in stdenv'.mkDerivation (finalAttrs: { '' ]; - env.NIX_LDFLAGS = lib.optionalString x11Support "-lX11 -lXext "; - # Ensure we reference 'lib' (not 'out') of Swift. preConfigure = lib.optionalString swiftSupport '' export SWIFT_LIB_DYNAMIC="${lib.getLib swift.swift}/lib/swift/macosx"