1{
2 lib,
3 buildLua,
4 fetchFromGitHub,
5 fetchpatch,
6 python3,
7 nix-update-script,
8}:
9
10# Usage: `pkgs.mpv.override { scripts = [ pkgs.mpvScripts.sponsorblock ]; }`
11buildLua {
12 pname = "mpv_sponsorblock";
13 version = "0-unstable-2023-01-30";
14
15 src = fetchFromGitHub {
16 owner = "po5";
17 repo = "mpv_sponsorblock";
18 rev = "7785c1477103f2fafabfd65fdcf28ef26e6d7f0d";
19 sha256 = "sha256-iUXaTWWFEdxhxClu2NYbQcThlvYty3A2dEYGooeAVAQ=";
20 };
21
22 patches = [
23 # Use XDG_DATA_HOME and XDG_CACHE_HOME if defined for UID and DB
24 # Necessary to avoid sponsorblock to write in the nix store at runtime.
25 # https://github.com/po5/mpv_sponsorblock/pull/17
26 (fetchpatch {
27 url = "https://github.com/po5/mpv_sponsorblock/pull/17/commits/e65b360a7d03a3430b4829e457a6670b2f617b09.patch";
28 sha256 = "00wv0pvbz0dz2ibka66zhl2jk0pil4pyv6ipjfz37i81q6szyhs5";
29 })
30 (fetchpatch {
31 url = "https://github.com/po5/mpv_sponsorblock/pull/17/commits/3832304d959205e99120a14c0560ed3c37104b08.patch";
32 sha256 = "149ffvn714n2m3mqs8mgrbs24bcr74kqfkx7wyql36ndhm88xd2z";
33 })
34 ];
35
36 postPatch = ''
37 substituteInPlace sponsorblock.lua \
38 --replace-fail "python3" "${lib.getExe python3}" \
39 --replace-fail 'mp.find_config_file("scripts")' "\"$out/share/mpv/scripts\""
40 '';
41
42 extraScripts = [ "sponsorblock_shared" ];
43
44 passthru.updateScript = nix-update-script { extraArgs = [ "--version=branch" ]; };
45
46 meta = with lib; {
47 description = "Script for mpv to skip sponsored segments of YouTube videos";
48 homepage = "https://github.com/po5/mpv_sponsorblock";
49 license = licenses.gpl3;
50 maintainers = with maintainers; [ euxane ];
51 };
52}