about summary refs log tree commit diff
path: root/nixpkgs/pkgs/applications/video/mpv
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/applications/video/mpv')
-rw-r--r--nixpkgs/pkgs/applications/video/mpv/default.nix127
-rw-r--r--nixpkgs/pkgs/applications/video/mpv/scripts/acompressor.nix27
-rw-r--r--nixpkgs/pkgs/applications/video/mpv/scripts/inhibit-gnome.nix31
-rw-r--r--nixpkgs/pkgs/applications/video/mpv/scripts/mpris.nix5
-rw-r--r--nixpkgs/pkgs/applications/video/mpv/scripts/mpv-playlistmanager.nix13
-rw-r--r--nixpkgs/pkgs/applications/video/mpv/scripts/mpvacious.nix19
-rw-r--r--nixpkgs/pkgs/applications/video/mpv/scripts/occivink.nix53
-rw-r--r--nixpkgs/pkgs/applications/video/mpv/scripts/sponsorblock.nix12
-rw-r--r--nixpkgs/pkgs/applications/video/mpv/scripts/thumbfast.nix38
-rw-r--r--nixpkgs/pkgs/applications/video/mpv/scripts/thumbnail.nix9
-rw-r--r--nixpkgs/pkgs/applications/video/mpv/scripts/uosc.nix48
-rwxr-xr-xnixpkgs/pkgs/applications/video/mpv/scripts/update-sponsorblock.sh49
-rw-r--r--nixpkgs/pkgs/applications/video/mpv/scripts/webtorrent-mpv-hook.nix40
-rw-r--r--nixpkgs/pkgs/applications/video/mpv/wrapper.nix3
14 files changed, 343 insertions, 131 deletions
diff --git a/nixpkgs/pkgs/applications/video/mpv/default.nix b/nixpkgs/pkgs/applications/video/mpv/default.nix
index cf81c0e0446c..68a8624c5eed 100644
--- a/nixpkgs/pkgs/applications/video/mpv/default.nix
+++ b/nixpkgs/pkgs/applications/video/mpv/default.nix
@@ -5,12 +5,11 @@
 , fetchpatch
 , addOpenGLRunpath
 , docutils
-, perl
+, meson
+, ninja
 , pkg-config
 , python3
-, wafHook
-, which
-, ffmpeg
+, ffmpeg_5
 , freefont_ttf
 , freetype
 , libass
@@ -19,11 +18,12 @@
 , lua
 , libuchardet
 , libiconv
-, CoreFoundation, Cocoa, CoreAudio, MediaPlayer
+, xcbuild
 
 , waylandSupport ? stdenv.isLinux
   , wayland
   , wayland-protocols
+  , wayland-scanner
   , libxkbcommon
 
 , x11Support ? stdenv.isLinux
@@ -40,7 +40,7 @@
 
 , vulkanSupport ? stdenv.isLinux
   , libplacebo
-  , shaderc
+  , shaderc # instead of spirv-cross
   , vulkan-headers
   , vulkan-loader
 
@@ -55,82 +55,97 @@
 , cacaSupport        ? true,           libcaca
 , 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
-, rubberbandSupport  ? stdenv.isLinux, rubberband
+, pipewireSupport    ? stdenv.isLinux, pipewire
+, rubberbandSupport  ? true,           rubberband
 , screenSaverSupport ? true,           libXScrnSaver
 , sdl2Support        ? true,           SDL2
 , sixelSupport       ? false,          libsixel
 , speexSupport       ? true,           speex
-, swiftSupport       ? false,          swift
+, swiftSupport       ? stdenv.isDarwin && stdenv.isAarch64, swift
 , theoraSupport      ? true,           libtheora
-, vaapiSupport       ? stdenv.isLinux, libva
+, vaapiSupport       ? x11Support || waylandSupport, libva
 , vapoursynthSupport ? false,          vapoursynth
 , vdpauSupport       ? true,           libvdpau
 , xineramaSupport    ? stdenv.isLinux, libXinerama
 , xvSupport          ? stdenv.isLinux, libXv
 , zimgSupport        ? true,           zimg
+, darwin
 }:
 
-with lib;
-
 let
+  inherit (darwin.apple_sdk_11_0.frameworks)
+    AVFoundation CoreFoundation CoreMedia Cocoa CoreAudio MediaPlayer Accelerate;
   luaEnv = lua.withPackages (ps: with ps; [ luasocket ]);
-
-in stdenv.mkDerivation rec {
+in stdenv.mkDerivation (finalAttrs: {
   pname = "mpv";
-  version = "0.34.1";
+  version = "0.35.1";
 
   outputs = [ "out" "dev" "man" ];
 
   src = fetchFromGitHub {
     owner = "mpv-player";
     repo = "mpv";
-    rev = "v${version}";
-    sha256 = "12qxwm1ww5vhjddl8yvj1xa0n1fi9z3lmzwhaiday2v59ca0qgsk";
+    rev = "v${finalAttrs.version}";
+    sha256 = "sha256-CoYTX9hgxLo72YdMoa0sEywg4kybHbFsypHk1rCM6tM=";
   };
 
+  patches = [
+    (fetchpatch {
+      # fixes EDL error on youtube DASH streams https://github.com/mpv-player/mpv/issues/11392
+      # to be removed on next release
+      url = "https://github.com/mpv-player/mpv/commit/94c189dae76ba280d9883b16346c3dfb9720687e.patch";
+      sha256 = "sha256-GeAltLAwkOKk82YfXYSrkNEX08uPauh7+kVbBGPWeT8=";
+    })
+  ];
+
   postPatch = ''
-    patchShebangs ./TOOLS/
+    patchShebangs version.* ./TOOLS/
+  '';
+
+  NIX_LDFLAGS = lib.optionalString x11Support "-lX11 -lXext ";
+
+  preConfigure = lib.optionalString swiftSupport ''
+    # Ensure we reference 'lib' (not 'out') of Swift.
+    export SWIFT_LIB_DYNAMIC=${lib.getLib swift.swift}/lib/swift/macosx
   '';
 
-  NIX_LDFLAGS = lib.optionalString x11Support "-lX11 -lXext "
-    + lib.optionalString stdenv.isDarwin "-framework CoreFoundation";
-
-  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 stdenv.isLinux  "dvbin")
-  ] # Disable whilst Swift isn't supported
-    ++ lib.optional (!swiftSupport) "--disable-macos-cocoa-cb";
+  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)
+  ];
+
+  mesonAutoFeatures = "auto";
 
   nativeBuildInputs = [
     addOpenGLRunpath
-    docutils
-    perl
+    docutils # for rst2man
+    meson
+    ninja
     pkg-config
     python3
-    wafHook
-    which
-  ] ++ lib.optionals swiftSupport [ swift ];
+  ]
+  ++ lib.optionals stdenv.isDarwin [ xcbuild.xcrun ]
+  ++ lib.optionals swiftSupport [ swift ]
+  ++ lib.optionals waylandSupport [ wayland-scanner ];
 
   buildInputs = [
-    ffmpeg
+    ffmpeg_5
     freetype
     libass
     libpthreadstubs
@@ -149,6 +164,7 @@ in stdenv.mkDerivation rec {
     ++ 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 ]
@@ -167,12 +183,13 @@ in stdenv.mkDerivation rec {
     ++ lib.optionals zimgSupport        [ zimg ]
     ++ lib.optionals stdenv.isLinux     [ nv-codec-headers ]
     ++ lib.optionals stdenv.isDarwin    [ libiconv ]
-    ++ lib.optionals stdenv.isDarwin    [ CoreFoundation Cocoa CoreAudio MediaPlayer ];
-
-  enableParallelBuilding = true;
+    ++ lib.optionals stdenv.isDarwin    [ CoreFoundation Cocoa CoreAudio MediaPlayer Accelerate ]
+    ++ lib.optionals (stdenv.isDarwin && swiftSupport) [ AVFoundation CoreMedia ];
 
   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 = ''
@@ -180,16 +197,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"
+    sed -i '/Icon=/ ! s/mpv/umpv/g; s/^Exec=.*/Exec=umpv %U/' $out/share/applications/umpv.desktop
   '' + 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.
@@ -219,8 +233,9 @@ in stdenv.mkDerivation rec {
       mpv is a free and open-source general-purpose video player, based on the
       MPlayer and mplayer2 projects, with great improvements above both.
     '';
+    changelog = "https://github.com/mpv-player/mpv/releases/tag/v${finalAttrs.version}";
     license = licenses.gpl2Plus;
     maintainers = with maintainers; [ AndersonTorres fpletz globin ma27 tadeokondrak ];
-    platforms = platforms.darwin ++ platforms.linux;
+    platforms = platforms.unix;
   };
-}
+})
diff --git a/nixpkgs/pkgs/applications/video/mpv/scripts/acompressor.nix b/nixpkgs/pkgs/applications/video/mpv/scripts/acompressor.nix
new file mode 100644
index 000000000000..d10ef5f9df75
--- /dev/null
+++ b/nixpkgs/pkgs/applications/video/mpv/scripts/acompressor.nix
@@ -0,0 +1,27 @@
+{ stdenvNoCC
+, mpv-unwrapped
+, lib
+}:
+
+stdenvNoCC.mkDerivation rec {
+  pname = "mpv-acompressor";
+  version = mpv-unwrapped.version;
+
+  src = "${mpv-unwrapped.src.outPath}/TOOLS/lua/acompressor.lua";
+
+  dontBuild = true;
+  dontUnpack = true;
+
+  installPhase = ''
+    install -Dm644 ${src} $out/share/mpv/scripts/acompressor.lua
+  '';
+
+  passthru.scriptName = "acompressor.lua";
+
+  meta = with lib; {
+    description = "Script to toggle and control ffmpeg's dynamic range compression filter.";
+    homepage = "https://github.com/mpv-player/mpv/blob/master/TOOLS/lua/acompressor.lua";
+    license = licenses.gpl2Plus;
+    maintainers = with maintainers; [ nicoo ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/video/mpv/scripts/inhibit-gnome.nix b/nixpkgs/pkgs/applications/video/mpv/scripts/inhibit-gnome.nix
new file mode 100644
index 000000000000..2955dfb7c0c8
--- /dev/null
+++ b/nixpkgs/pkgs/applications/video/mpv/scripts/inhibit-gnome.nix
@@ -0,0 +1,31 @@
+{ lib, stdenv, fetchFromGitHub, pkg-config, dbus, mpv-unwrapped }:
+
+stdenv.mkDerivation rec {
+  pname = "mpv-inhibit-gnome";
+  version = "0.1.3";
+
+  src = fetchFromGitHub {
+    owner = "Guldoman";
+    repo = "mpv_inhibit_gnome";
+    rev = "v${version}";
+    hash = "sha256-LSGg5gAQE2JpepBqhz6D6d3NlqYaU4bjvYf1F+oLphQ=";
+  };
+
+  nativeBuildInputs = [ pkg-config ];
+
+  buildInputs = [ dbus mpv-unwrapped ];
+
+  passthru.scriptName = "mpv_inhibit_gnome.so";
+
+  installPhase = ''
+    install -D ./lib/mpv_inhibit_gnome.so $out/share/mpv/scripts/mpv_inhibit_gnome.so
+  '';
+
+  meta = with lib; {
+    description = "This mpv plugin prevents screen blanking in GNOME";
+    homepage = "https://github.com/Guldoman/mpv_inhibit_gnome";
+    license = licenses.mit;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ myaats ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/video/mpv/scripts/mpris.nix b/nixpkgs/pkgs/applications/video/mpv/scripts/mpris.nix
index 89458e4925b0..063833297b98 100644
--- a/nixpkgs/pkgs/applications/video/mpv/scripts/mpris.nix
+++ b/nixpkgs/pkgs/applications/video/mpv/scripts/mpris.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   pname = "mpv-mpris";
-  version = "0.8.1";
+  version = "1.0";
 
   src = fetchFromGitHub {
     owner = "hoyon";
     repo = "mpv-mpris";
     rev = version;
-    sha256 = "ugEiQZA1vQCVwyv3ViM84Qz8lhRvy17vcxjayYevTAs=";
+    sha256 = "sha256-7kPpCfiWe58V4fBOsEVvGoGeNIlMUAyD1fqS5/8k/e4=";
   };
 
   nativeBuildInputs = [ pkg-config ];
@@ -28,5 +28,6 @@ stdenv.mkDerivation rec {
     license = licenses.mit;
     platforms = platforms.linux;
     maintainers = with maintainers; [ jfrankenau ];
+    changelog = "https://github.com/hoyon/mpv-mpris/releases/tag/${version}";
   };
 }
diff --git a/nixpkgs/pkgs/applications/video/mpv/scripts/mpv-playlistmanager.nix b/nixpkgs/pkgs/applications/video/mpv/scripts/mpv-playlistmanager.nix
index a1179ef7aa3a..b59f9de38714 100644
--- a/nixpkgs/pkgs/applications/video/mpv/scripts/mpv-playlistmanager.nix
+++ b/nixpkgs/pkgs/applications/video/mpv/scripts/mpv-playlistmanager.nix
@@ -1,27 +1,26 @@
-{ lib, stdenvNoCC, fetchFromGitHub, youtube-dl }:
+{ lib, stdenvNoCC, fetchFromGitHub, yt-dlp }:
 
 stdenvNoCC.mkDerivation rec {
   pname = "mpv-playlistmanager";
-  version = "unstable-2021-09-27";
+  version = "unstable-2022-08-26";
 
   src = fetchFromGitHub {
     owner = "jonniek";
     repo = "mpv-playlistmanager";
-    rev = "9a759b300c92b55e82be5824fe058e263975741a";
-    sha256 = "qMzDJlouBptwyNdw2ag4VKEtmkQNUlos0USPerBAV/s=";
+    rev = "07393162f7f78f8188e976f616f1b89813cec741";
+    sha256 = "sha256-Vgh5F6c90ijp5LVrP2cdAOXo+QtJ9aXI9G/3C2HGqd4=";
   };
 
   postPatch = ''
     substituteInPlace playlistmanager.lua \
-    --replace "'youtube-dl'" "'${youtube-dl}/bin/youtube-dl'" \
+      --replace "youtube-dl" "${lib.getBin yt-dlp}/bin/yt-dlp"
   '';
 
   dontBuild = true;
 
   installPhase = ''
     runHook preInstall
-    mkdir -p $out/share/mpv/scripts
-    cp playlistmanager.lua $out/share/mpv/scripts
+    install -D -t $out/share/mpv/scripts playlistmanager.lua
     runHook postInstall
   '';
 
diff --git a/nixpkgs/pkgs/applications/video/mpv/scripts/mpvacious.nix b/nixpkgs/pkgs/applications/video/mpv/scripts/mpvacious.nix
index 071f762ff4a7..2ba2b80cbdcb 100644
--- a/nixpkgs/pkgs/applications/video/mpv/scripts/mpvacious.nix
+++ b/nixpkgs/pkgs/applications/video/mpv/scripts/mpvacious.nix
@@ -8,28 +8,31 @@
 
 stdenvNoCC.mkDerivation rec {
   pname = "mpvacious";
-  version = "0.15";
+  version = "0.23";
 
   src = fetchFromGitHub {
     owner = "Ajatt-Tools";
     repo = "mpvacious";
     rev = "v${version}";
-    sha256 = "1lxlgbjk4x3skg5s7kkr9llcdlmpmabfrcslwhhz5f4j3bq7498w";
+    sha256 = "sha256-b0JUT5Y0u/H9p5whuFTU8EgQnKzFCUR2HA9NO+mxe04=";
   };
 
   postPatch = ''
-    substituteInPlace subs2srs.lua \
-      --replace "'curl'" "'${curl}/bin/curl'" \
-      --replace "'wl-copy'" "'${wl-clipboard}/bin/wl-copy'" \
-      --replace "xclip" "${xclip}/bin/xclip"
+    substituteInPlace utils/forvo.lua \
+      --replace "'curl" "'${curl}/bin/curl"
+    substituteInPlace platform/nix.lua \
+      --replace "'curl" "'${curl}/bin/curl" \
+      --replace "'wl-copy" "'${wl-clipboard}/bin/wl-copy" \
+      --replace "'xclip" "'${xclip}/bin/xclip"
   '';
 
   dontBuild = true;
 
   installPhase = ''
     runHook preInstall
-    mkdir -p $out/share/mpv/scripts/mpvacious
-    cp *.lua $out/share/mpv/scripts/mpvacious
+    rm -r .github
+    mkdir -p $out/share/mpv/scripts
+    cp -r . $out/share/mpv/scripts/mpvacious
     runHook postInstall
   '';
 
diff --git a/nixpkgs/pkgs/applications/video/mpv/scripts/occivink.nix b/nixpkgs/pkgs/applications/video/mpv/scripts/occivink.nix
new file mode 100644
index 000000000000..da723fd9102e
--- /dev/null
+++ b/nixpkgs/pkgs/applications/video/mpv/scripts/occivink.nix
@@ -0,0 +1,53 @@
+{ lib
+, stdenvNoCC
+, fetchFromGitHub
+}:
+
+let
+  script = { n, ... }@p:
+    stdenvNoCC.mkDerivation (lib.attrsets.recursiveUpdate {
+      pname = "mpv_${n}";
+      passthru.scriptName = "${n}.lua";
+
+      src = fetchFromGitHub {
+        owner = "occivink";
+        repo = "mpv-scripts";
+        rev = "af360f332897dda907644480f785336bc93facf1";
+        hash = "sha256-KdCrUkJpbxxqmyUHksVVc8KdMn8ivJeUA2eerFZfEE8=";
+      };
+      version = "unstable-2022-10-02";
+
+      dontBuild = true;
+      installPhase = ''
+        mkdir -p $out/share/mpv/scripts
+        cp -r scripts/${n}.lua $out/share/mpv/scripts/
+      '';
+
+      meta = with lib; {
+        homepage = "https://github.com/occivink/mpv-scripts";
+        license = licenses.unlicense;
+        platforms = platforms.all;
+        maintainers = with maintainers; [ nicoo ];
+      };
+
+      outputHashAlgo = "sha256";
+      outputHashMode = "recursive";
+    } p);
+
+in
+{
+
+  # Usage: `pkgs.mpv.override { scripts = [ pkgs.mpvScripts.seekTo ]; }`
+  seekTo = script {
+    n = "seek-to";
+    meta.description = "Mpv script for seeking to a specific position";
+    outputHash = "sha256-3RlbtUivmeoR9TZ6rABiZSd5jd2lFv/8p/4irHMLshs=";
+  };
+
+  blacklistExtensions = script {
+    n = "blacklist-extensions";
+    meta.description = "Automatically remove playlist entries based on their extension.";
+    outputHash = "sha256-qw9lz8ofmvvh23F9aWLxiU4YofY+YflRETu+nxMhvVE=";
+  };
+
+}
diff --git a/nixpkgs/pkgs/applications/video/mpv/scripts/sponsorblock.nix b/nixpkgs/pkgs/applications/video/mpv/scripts/sponsorblock.nix
index 9a4060e59330..35f5fcb549f1 100644
--- a/nixpkgs/pkgs/applications/video/mpv/scripts/sponsorblock.nix
+++ b/nixpkgs/pkgs/applications/video/mpv/scripts/sponsorblock.nix
@@ -1,15 +1,15 @@
-{ lib, stdenvNoCC, fetchFromGitHub, fetchpatch, python3 }:
+{ lib, stdenvNoCC, fetchFromGitHub, fetchpatch, python3, nix-update-script }:
 
 # Usage: `pkgs.mpv.override { scripts = [ pkgs.mpvScripts.sponsorblock ]; }`
 stdenvNoCC.mkDerivation {
   pname = "mpv_sponsorblock";
-  version = "unstable-2021-12-23";
+  version = "unstable-2023-01-30";
 
   src = fetchFromGitHub {
     owner = "po5";
     repo = "mpv_sponsorblock";
-    rev = "6743bd47d4cfce3ae3d5dd4f587f3193bd4fb9b2";
-    sha256 = "06c37f33cdpz1w1jacjf1wnbh4f9b1xpipxzkg5ixf46cbwssmsj";
+    rev = "7785c1477103f2fafabfd65fdcf28ef26e6d7f0d";
+    sha256 = "sha256-iUXaTWWFEdxhxClu2NYbQcThlvYty3A2dEYGooeAVAQ=";
   };
 
   dontBuild = true;
@@ -41,7 +41,9 @@ stdenvNoCC.mkDerivation {
 
   passthru = {
     scriptName = "sponsorblock.lua";
-    updateScript = ./update-sponsorblock.sh;
+    updateScript = nix-update-script {
+      extraArgs = [ "--version=branch" ];
+    };
   };
 
   meta = with lib; {
diff --git a/nixpkgs/pkgs/applications/video/mpv/scripts/thumbfast.nix b/nixpkgs/pkgs/applications/video/mpv/scripts/thumbfast.nix
new file mode 100644
index 000000000000..fb231d87ca32
--- /dev/null
+++ b/nixpkgs/pkgs/applications/video/mpv/scripts/thumbfast.nix
@@ -0,0 +1,38 @@
+{ lib, stdenvNoCC, fetchFromGitHub, mpv-unwrapped }:
+
+stdenvNoCC.mkDerivation {
+  name = "mpv-thumbfast";
+  version = "unstable-2023-06-04";
+
+  src = fetchFromGitHub {
+    owner = "po5";
+    repo = "thumbfast";
+    rev = "6f1d92da25a7b807427f55f085e7ad4d60c4e0d7";
+    hash = "sha256-7CCxMPmZZRDIcWn+YbV4xzZFL80qZS5UFA25E+Y2P2Q=";
+  };
+
+  postPatch = ''
+    substituteInPlace thumbfast.lua \
+      --replace 'mpv_path = "mpv"' 'mpv_path = "${lib.getBin mpv-unwrapped}/bin/mpv"'
+  '';
+
+  dontBuild = true;
+
+  installPhase = ''
+    runHook preInstall
+
+    mkdir -p $out/share/mpv/scripts
+    cp -r thumbfast.lua $out/share/mpv/scripts/thumbfast.lua
+
+    runHook postInstall
+  '';
+
+  passthru.scriptName = "thumbfast.lua";
+
+  meta = {
+    description = "High-performance on-the-fly thumbnailer for mpv";
+    homepage = "https://github.com/po5/thumbfast";
+    license = lib.licenses.mpl20;
+    maintainers = with lib.maintainers; [ apfelkuchen6 ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/video/mpv/scripts/thumbnail.nix b/nixpkgs/pkgs/applications/video/mpv/scripts/thumbnail.nix
index 5de9f5b0c6b2..60b392a6aa27 100644
--- a/nixpkgs/pkgs/applications/video/mpv/scripts/thumbnail.nix
+++ b/nixpkgs/pkgs/applications/video/mpv/scripts/thumbnail.nix
@@ -1,14 +1,14 @@
 { lib, stdenvNoCC, fetchFromGitHub, python3 }:
 
 stdenvNoCC.mkDerivation rec {
-  pname = "mpv_thumbnail_script";
-  version = "0.4.9";
+  pname = "mpv-thumbnail-script";
+  version = "0.5.2";
 
   src = fetchFromGitHub {
     owner = "marzzzello";
-    repo = pname;
+    repo = "mpv_thumbnail_script";
     rev = version;
-    sha256 = "0dgfrb8ypc5vlq35kzn423fm6l6348ivl85vb6j3ccc9a51xprw3";
+    sha256 = "sha256-6J1eeuSYyUJmWLIl9WsQ4NzQOBJNO3Cnl5jcPEal4vM=";
   };
 
   nativeBuildInputs = [ python3 ];
@@ -29,6 +29,7 @@ stdenvNoCC.mkDerivation rec {
   meta = with lib; {
     description = "A lua script to show preview thumbnails in mpv's OSC seekbar";
     homepage = "https://github.com/marzzzello/mpv_thumbnail_script";
+    changelog = "https://github.com/marzzzello/mpv_thumbnail_script/releases/tag/${version}";
     license = licenses.gpl3Plus;
     platforms = platforms.all;
     maintainers = with maintainers; [ figsoda ];
diff --git a/nixpkgs/pkgs/applications/video/mpv/scripts/uosc.nix b/nixpkgs/pkgs/applications/video/mpv/scripts/uosc.nix
new file mode 100644
index 000000000000..b88cd2c5b968
--- /dev/null
+++ b/nixpkgs/pkgs/applications/video/mpv/scripts/uosc.nix
@@ -0,0 +1,48 @@
+{ stdenvNoCC, lib, fetchFromGitHub, makeFontsConf }:
+
+stdenvNoCC.mkDerivation (finalAttrs: {
+  pname = "uosc";
+  version = "4.7.0";
+
+  src = fetchFromGitHub {
+    owner = "tomasklaen";
+    repo = "uosc";
+    rev = finalAttrs.version;
+    hash = "sha256-JqlBjhwRgmXl6XfHYTwtNWZj656EDHjcdWOlCgihF5I=";
+  };
+
+  postPatch = ''
+    substituteInPlace scripts/uosc.lua \
+      --replace "mp.find_config_file('scripts')" "\"$out/share/mpv/scripts\""
+  '';
+
+  dontBuild = true;
+
+  installPhase = ''
+    runHook preInstall
+
+    mkdir -p $out/share/mpv/
+    cp -r scripts $out/share/mpv
+    cp -r fonts $out/share
+
+    runHook postInstall
+  '';
+
+  passthru.scriptName = "uosc.lua";
+  # the script uses custom "texture" fonts as the background for ui elements.
+  # In order for mpv to find them, we need to adjust the fontconfig search path.
+  passthru.extraWrapperArgs = [
+    "--set"
+    "FONTCONFIG_FILE"
+    (toString (makeFontsConf {
+      fontDirectories = [ "${finalAttrs.finalPackage}/share/fonts" ];
+    }))
+  ];
+
+  meta = with lib; {
+    description = "Feature-rich minimalist proximity-based UI for MPV player";
+    homepage = "https://github.com/tomasklaen/uosc";
+    license = licenses.gpl3Only;
+    maintainers = with lib.maintainers; [ apfelkuchen6 ];
+  };
+})
diff --git a/nixpkgs/pkgs/applications/video/mpv/scripts/update-sponsorblock.sh b/nixpkgs/pkgs/applications/video/mpv/scripts/update-sponsorblock.sh
deleted file mode 100755
index b4888365a6f3..000000000000
--- a/nixpkgs/pkgs/applications/video/mpv/scripts/update-sponsorblock.sh
+++ /dev/null
@@ -1,49 +0,0 @@
-#!/usr/bin/env nix-shell
-#!nix-shell -i bash -p common-updater-scripts git jq nix nix-prefetch-git
-git_url='https://github.com/po5/mpv_sponsorblock.git'
-git_branch='master'
-git_dir='/var/tmp/mpv_sponsorblock.git'
-nix_file="$(dirname "${BASH_SOURCE[0]}")/sponsorblock.nix"
-pkg='mpvScripts.sponsorblock'
-
-set -euo pipefail
-
-info() {
-    if [ -t 2 ]; then
-        set -- '\033[32m%s\033[39m\n' "$@"
-    else
-        set -- '%s\n' "$@"
-    fi
-    printf "$@" >&2
-}
-
-old_rev=$(nix-instantiate --eval --strict --json -A "$pkg.src.rev" | jq -r)
-old_version=$(nix-instantiate --eval --strict --json -A "$pkg.version" | jq -r)
-today=$(LANG=C date -u +'%Y-%m-%d')
-
-info "fetching $git_url..."
-if [ ! -d "$git_dir" ]; then
-    git init --initial-branch="$git_branch" "$git_dir"
-    git -C "$git_dir" remote add origin "$git_url"
-fi
-git -C "$git_dir" fetch origin "$git_branch"
-
-# use latest commit before today, we should not call the version *today*
-# because there might still be commits coming
-# use the day of the latest commit we picked as version
-new_rev=$(git -C "$git_dir" log -n 1 --format='format:%H' --before="${today}T00:00:00Z" "origin/$git_branch")
-new_version="unstable-$(git -C "$git_dir" log -n 1 --format='format:%cs' "$new_rev")"
-info "latest commit before $today: $new_rev"
-
-if [ "$new_rev" = "$old_rev" ]; then
-    info "$pkg is up-to-date."
-    exit
-fi
-
-new_sha256=$(nix-prefetch-git --rev "$new_rev" "$git_dir" | jq -r .sha256)
-update-source-version "$pkg" \
-    "$new_version" \
-    "$new_sha256" \
-    --rev="$new_rev"
-git add "$nix_file"
-git commit --verbose --message "$pkg: $old_version -> $new_version"
diff --git a/nixpkgs/pkgs/applications/video/mpv/scripts/webtorrent-mpv-hook.nix b/nixpkgs/pkgs/applications/video/mpv/scripts/webtorrent-mpv-hook.nix
new file mode 100644
index 000000000000..a1713e24375f
--- /dev/null
+++ b/nixpkgs/pkgs/applications/video/mpv/scripts/webtorrent-mpv-hook.nix
@@ -0,0 +1,40 @@
+{ lib, buildNpmPackage, fetchFromGitHub, nodejs, python3 }:
+
+buildNpmPackage rec {
+  pname = "webtorrent-mpv-hook";
+  version = "1.3.3";
+
+  src = fetchFromGitHub {
+    owner = "mrxdst";
+    repo = pname;
+    rev = "v${version}";
+    hash = "sha256-AFKX31kriacXygZy0Mw+QwO+SwFEu13687mJ/WeAoKY=";
+  };
+
+  postPatch = ''
+    substituteInPlace src/webtorrent.ts --replace "node_path: 'node'" "node_path: '${nodejs}/bin/node'"
+    # This executable is just for telling non-Nix users how to install
+    substituteInPlace package.json --replace '"bin": "build/bin.js",' ""
+    rm -rf src/bin.ts
+  '';
+
+  npmDepsHash = "sha256-GpNUJ5ZCgMjSYLqsIE/RwkTSFT3uAhxrHPe7XvGDRHE=";
+  makeCacheWritable = true;
+
+  nativeBuildInputs = [
+    python3 # Fixes node-gyp on aarch64-linux
+  ];
+
+  postInstall = ''
+    mkdir -p $out/share/mpv/scripts/
+    ln -s $out/lib/node_modules/webtorrent-mpv-hook/build/webtorrent.js $out/share/mpv/scripts/
+  '';
+  passthru.scriptName = "webtorrent.js";
+
+  meta = {
+    description = "Adds a hook that allows mpv to stream torrents";
+    homepage = "https://github.com/mrxdst/webtorrent-mpv-hook";
+    maintainers = [ lib.maintainers.chuangzhu ];
+    license = lib.licenses.isc;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/video/mpv/wrapper.nix b/nixpkgs/pkgs/applications/video/mpv/wrapper.nix
index e9be744ed01c..0dd735071f00 100644
--- a/nixpkgs/pkgs/applications/video/mpv/wrapper.nix
+++ b/nixpkgs/pkgs/applications/video/mpv/wrapper.nix
@@ -18,6 +18,7 @@ let
     # expected to have a `scriptName` passthru attribute that points to the
     # name of the script that would reside in the script's derivation's
     # `$out/share/mpv/scripts/`.
+    # A script can optionally also provide an `extraWrapperArgs` passthru attribute.
     scripts ? [],
     extraUmpvWrapperArgs ? []
   }:
@@ -49,6 +50,8 @@ let
           # attribute of the script derivation from the `scripts`
           "--script=${script}/share/mpv/scripts/${script.scriptName}"
         ]
+        # scripts can also set the `extraWrapperArgs` passthru
+        ++ (script.extraWrapperArgs or [])
       ) scripts
     )) ++ extraMakeWrapperArgs)
     ;