diff options
author | schnusch <schnusch@users.noreply.github.com> | 2022-11-23 23:25:32 +0100 |
---|---|---|
committer | schnusch <schnusch@users.noreply.github.com> | 2022-11-28 12:18:02 +0100 |
commit | fe0257891bbc5c39b6c225e0c35633d9da478404 (patch) | |
tree | 220093ef62d958eb0570696a5fab02333fdd38a2 /pkgs/applications/video/mpv | |
parent | f5d62d419e86249c9910f43d6d6c4e9c156d3ac3 (diff) |
mpvScripts.sponsorblock: replace update script with nix-update
Diffstat (limited to 'pkgs/applications/video/mpv')
-rw-r--r-- | pkgs/applications/video/mpv/scripts/sponsorblock.nix | 7 | ||||
-rwxr-xr-x | pkgs/applications/video/mpv/scripts/update-sponsorblock.sh | 49 |
2 files changed, 5 insertions, 51 deletions
diff --git a/pkgs/applications/video/mpv/scripts/sponsorblock.nix b/pkgs/applications/video/mpv/scripts/sponsorblock.nix index 2db4cf53d004..b43ce6afdff8 100644 --- a/pkgs/applications/video/mpv/scripts/sponsorblock.nix +++ b/pkgs/applications/video/mpv/scripts/sponsorblock.nix @@ -1,4 +1,4 @@ -{ lib, stdenvNoCC, fetchFromGitHub, fetchpatch, python3 }: +{ lib, stdenvNoCC, fetchFromGitHub, fetchpatch, python3, nix-update-script }: # Usage: `pkgs.mpv.override { scripts = [ pkgs.mpvScripts.sponsorblock ]; }` stdenvNoCC.mkDerivation { @@ -41,7 +41,10 @@ stdenvNoCC.mkDerivation { passthru = { scriptName = "sponsorblock.lua"; - updateScript = ./update-sponsorblock.sh; + updateScript = nix-update-script { + attrPath = "mpvScripts.sponsorblock"; + extraArgs = [ "--version=branch" ]; + }; }; meta = with lib; { diff --git a/pkgs/applications/video/mpv/scripts/update-sponsorblock.sh b/pkgs/applications/video/mpv/scripts/update-sponsorblock.sh deleted file mode 100755 index b4888365a6f3..000000000000 --- a/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" |