about summary refs log tree commit diff
path: root/nixpkgs/pkgs/applications/video/mpv/scripts
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2023-06-16 06:56:35 +0000
committerAlyssa Ross <hi@alyssa.is>2023-06-16 06:56:35 +0000
commit99fcaeccb89621dd492203ce1f2d551c06f228ed (patch)
tree41cb730ae07383004789779b0f6e11cb3f4642a3 /nixpkgs/pkgs/applications/video/mpv/scripts
parent59c5f5ac8682acc13bb22bc29c7cf02f7d75f01f (diff)
parent75a5ebf473cd60148ba9aec0d219f72e5cf52519 (diff)
downloadnixlib-99fcaeccb89621dd492203ce1f2d551c06f228ed.tar
nixlib-99fcaeccb89621dd492203ce1f2d551c06f228ed.tar.gz
nixlib-99fcaeccb89621dd492203ce1f2d551c06f228ed.tar.bz2
nixlib-99fcaeccb89621dd492203ce1f2d551c06f228ed.tar.lz
nixlib-99fcaeccb89621dd492203ce1f2d551c06f228ed.tar.xz
nixlib-99fcaeccb89621dd492203ce1f2d551c06f228ed.tar.zst
nixlib-99fcaeccb89621dd492203ce1f2d551c06f228ed.zip
Merge branch 'nixos-unstable' of https://github.com/NixOS/nixpkgs
Conflicts:
	nixpkgs/nixos/modules/config/console.nix
	nixpkgs/nixos/modules/services/mail/mailman.nix
	nixpkgs/nixos/modules/services/mail/public-inbox.nix
	nixpkgs/nixos/modules/services/mail/rss2email.nix
	nixpkgs/nixos/modules/services/networking/ssh/sshd.nix
	nixpkgs/pkgs/applications/networking/instant-messengers/dino/default.nix
	nixpkgs/pkgs/applications/networking/irc/weechat/default.nix
	nixpkgs/pkgs/applications/window-managers/sway/default.nix
	nixpkgs/pkgs/build-support/go/module.nix
	nixpkgs/pkgs/build-support/rust/build-rust-package/default.nix
	nixpkgs/pkgs/development/interpreters/python/default.nix
	nixpkgs/pkgs/development/node-packages/overrides.nix
	nixpkgs/pkgs/development/tools/b4/default.nix
	nixpkgs/pkgs/servers/dict/dictd-db.nix
	nixpkgs/pkgs/servers/mail/public-inbox/default.nix
	nixpkgs/pkgs/tools/security/pinentry/default.nix
	nixpkgs/pkgs/tools/text/unoconv/default.nix
	nixpkgs/pkgs/top-level/all-packages.nix
Diffstat (limited to 'nixpkgs/pkgs/applications/video/mpv/scripts')
-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
12 files changed, 269 insertions, 75 deletions
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;
+  };
+}