summary refs log tree commit diff
path: root/pkgs/applications/video/mpv/default.nix
diff options
context:
space:
mode:
authorSandro Jäckel <sandro.jaeckel@gmail.com>2022-11-12 19:10:13 +0100
committerSandro Jäckel <sandro.jaeckel@sap.com>2022-11-29 17:16:49 +0100
commit683293089feb2c517689525bddcf5cd237f2b751 (patch)
tree767ffb53593167cbab318acc3fdfe343b6ddaa8e /pkgs/applications/video/mpv/default.nix
parent506f41b6add695a75c30fb2701079a3464993b41 (diff)
downloadnixpkgs-683293089feb2c517689525bddcf5cd237f2b751.tar
nixpkgs-683293089feb2c517689525bddcf5cd237f2b751.tar.gz
nixpkgs-683293089feb2c517689525bddcf5cd237f2b751.tar.bz2
nixpkgs-683293089feb2c517689525bddcf5cd237f2b751.tar.lz
nixpkgs-683293089feb2c517689525bddcf5cd237f2b751.tar.xz
nixpkgs-683293089feb2c517689525bddcf5cd237f2b751.tar.zst
nixpkgs-683293089feb2c517689525bddcf5cd237f2b751.zip
mpv-unwrapped: build with meson
xcrun is required for darwin to find its SDK location and for the version detection.

Co-authored-by: adisbladis <adisbladis@gmail.com>
Co-authored-by: Anderson Torres <torres.anderson.85@protonmail.com>
Co-authored-by: Atemu <atemu.main@gmail.com>
Diffstat (limited to 'pkgs/applications/video/mpv/default.nix')
-rw-r--r--pkgs/applications/video/mpv/default.nix73
1 files changed, 33 insertions, 40 deletions
diff --git a/pkgs/applications/video/mpv/default.nix b/pkgs/applications/video/mpv/default.nix
index 05ec95d006b..11203b62df5 100644
--- a/pkgs/applications/video/mpv/default.nix
+++ b/pkgs/applications/video/mpv/default.nix
@@ -4,11 +4,10 @@
 , fetchFromGitHub
 , addOpenGLRunpath
 , docutils
-, perl
+, meson
+, ninja
 , pkg-config
 , python3
-, wafHook
-, which
 , ffmpeg
 , freefont_ttf
 , freetype
@@ -19,6 +18,7 @@
 , libuchardet
 , libiconv
 , CoreFoundation, Cocoa, CoreAudio, MediaPlayer
+, xcbuild
 
 , waylandSupport ? stdenv.isLinux
   , wayland
@@ -97,40 +97,36 @@ in stdenv.mkDerivation rec {
     patchShebangs version.* ./TOOLS/
   '';
 
-  NIX_LDFLAGS = lib.optionalString x11Support "-lX11 -lXext "
-    + lib.optionalString stdenv.isDarwin "-framework CoreFoundation";
-
-  # These flags are not supported and cause the build
-  # to fail, even when cross compilation itself works.
-  dontAddWafCrossFlags = true;
-
-  wafConfigureFlags = [
-    "--enable-libmpv-shared"
-    "--enable-manpage-build"
-    "--disable-libmpv-static"
-    "--disable-static-build"
-    "--disable-build-date" # Purity
-    (lib.enableFeature archiveSupport  "libarchive")
-    (lib.enableFeature cddaSupport     "cdda")
-    (lib.enableFeature dvdnavSupport   "dvdnav")
-    (lib.enableFeature javascriptSupport "javascript")
-    (lib.enableFeature openalSupport   "openal")
-    (lib.enableFeature sdl2Support     "sdl2")
-    (lib.enableFeature sixelSupport    "sixel")
-    (lib.enableFeature vaapiSupport    "vaapi")
-    (lib.enableFeature waylandSupport  "wayland")
-    (lib.enableFeature dvbinSupport  "dvbin")
-  ] # Disable whilst Swift isn't supported
-    ++ lib.optional (!swiftSupport) "--disable-macos-cocoa-cb";
+  NIX_LDFLAGS = lib.optionalString x11Support "-lX11 -lXext ";
+
+  mesonFlags = let
+    mesonFeatureFlag = feature: flag: "-D${feature}=${if flag then "enabled" else "disabled"}";
+  in [
+    "-Ddefault_library=shared"
+    "-Dlibmpv=true"
+    (mesonFeatureFlag "libarchive" archiveSupport)
+    (mesonFeatureFlag "manpage-build" true)
+    (mesonFeatureFlag "cdda" cddaSupport)
+    (mesonFeatureFlag "dvbin" dvbinSupport)
+    (mesonFeatureFlag "dvdnav" dvdnavSupport)
+    (mesonFeatureFlag "openal" openalSupport)
+    (mesonFeatureFlag "sdl2" sdl2Support)
+    # Disable whilst Swift isn't supported
+    (mesonFeatureFlag "swift-build" swiftSupport)
+    (mesonFeatureFlag "macos-cocoa-cb" swiftSupport)
+  ];
+
+  mesonAutoFeatures = "auto";
 
   nativeBuildInputs = [
     addOpenGLRunpath
     docutils # for rst2man
-    perl
+    meson
+    ninja
     pkg-config
     python3
-    wafHook
-    which
+  ] ++ lib.optionals stdenv.isDarwin [
+    xcbuild.xcrun
   ] ++ lib.optionals swiftSupport [ swift ]
     ++ lib.optionals waylandSupport [ wayland-scanner ];
 
@@ -175,10 +171,10 @@ in stdenv.mkDerivation rec {
     ++ lib.optionals stdenv.isDarwin    [ libiconv ]
     ++ lib.optionals stdenv.isDarwin    [ CoreFoundation Cocoa CoreAudio MediaPlayer ];
 
-  enableParallelBuilding = true;
-
   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
+    popd
   '';
 
   postInstall = ''
@@ -186,16 +182,13 @@ in stdenv.mkDerivation rec {
     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 ../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' $out/share/applications/umpv.desktop
-
-    substituteInPlace $out/lib/pkgconfig/mpv.pc \
-      --replace "$out/include" "$dev/include"
   '' + lib.optionalString stdenv.isDarwin ''
     mkdir -p $out/Applications
-    cp -r build/mpv.app $out/Applications
+    cp -r mpv.app $out/Applications
   '';
 
   # Set RUNPATH so that libcuda in /run/opengl-driver(-32)/lib can be found.
@@ -227,6 +220,6 @@ in stdenv.mkDerivation rec {
     '';
     license = licenses.gpl2Plus;
     maintainers = with maintainers; [ AndersonTorres fpletz globin ma27 tadeokondrak ];
-    platforms = platforms.darwin ++ platforms.linux;
+    platforms = platforms.unix;
   };
 }