diff --git a/pkgs/servers/invidious/default.nix b/pkgs/servers/invidious/default.nix index cf2de4c5a94d..b02fccec080c 100644 --- a/pkgs/servers/invidious/default.nix +++ b/pkgs/servers/invidious/default.nix @@ -16,8 +16,7 @@ let in crystal.buildCrystalPackage rec { pname = "invidious"; - version = "2.20240427"; - # inherit (versions.invidious) version; + inherit (versions.invidious) version; src = fetchFromGitea { domain = "gitea.invidious.io"; @@ -25,8 +24,7 @@ crystal.buildCrystalPackage rec { repo = pname; fetchSubmodules = true; rev = "v${version}"; - hash = "sha256-YZ+uhn1ESuRTZxAMoxKCpxEaUfeCUqOrSr3LkdbrTkU="; - # inherit (versions.invidious) rev hash; + inherit (versions.invidious) hash; }; postPatch = diff --git a/pkgs/servers/invidious/update.sh b/pkgs/servers/invidious/update.sh index 82c8186bebc4..64911449630c 100755 --- a/pkgs/servers/invidious/update.sh +++ b/pkgs/servers/invidious/update.sh @@ -1,5 +1,5 @@ #!/usr/bin/env nix-shell -#!nix-shell -i bash -p curl crystal crystal2nix jq git moreutils nix nix-prefetch pkg-config pcre +#!nix-shell -i bash -p curl crystal crystal2nix jq git moreutils nix nix-prefetch pkg-config pcre gnugrep git_url='https://github.com/iv-org/invidious.git' git_branch='master' git_dir='/var/tmp/invidious.git' @@ -26,7 +26,6 @@ json_set() { jq --arg x "$2" "$1 = \$x" < 'versions.json' | sponge 'versions.json' } -old_rev=$(json_get '.invidious.rev') old_version=$(json_get '.invidious.version') today=$(LANG=C date -u +'%Y-%m-%d') @@ -37,38 +36,30 @@ if [ ! -d "$git_dir" ]; then fi git -C "$git_dir" fetch origin --tags "$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_tag=$(git -C "$git_dir" describe --tags --abbrev=0 "$new_rev") -new_version="$new_tag-unstable-$(TZ=UTC git -C "$git_dir" log -n 1 --date='format-local:%Y-%m-%d' --format='%cd' "$new_rev")" -info "latest commit before $today: $new_rev" +new_tag="$(git -C "$git_dir" ls-remote --tags --sort=committerdate origin | head -n1 | grep -Po '(?<=refs/tags/).*')" +new_version="${new_tag#v}" -if [ "$new_rev" = "$old_rev" ]; then +if [ "$new_version" = "$old_version" ]; then info "$pkg is up-to-date." exit fi json_set '.invidious.version' "$new_version" -json_set '.invidious.rev' "$new_rev" new_hash=$(nix-prefetch -I 'nixpkgs=../../..' "$pkg") json_set '.invidious.hash' "$new_hash" -commit_msg="$pkg: $old_version -> $new_version" # fetch video.js dependencies info "Running scripts/fetch-player-dependencies.cr..." -git -C "$git_dir" reset --hard "$new_rev" +git -C "$git_dir" reset --hard "$new_tag" (cd "$git_dir" && crystal run scripts/fetch-player-dependencies.cr -- --minified) rm -f "$git_dir/assets/videojs/.gitignore" videojs_new_hash=$(nix-hash --type sha256 --sri "$git_dir/assets/videojs") json_set '.videojs.hash' "$videojs_new_hash" -if git -C "$git_dir" diff-tree --quiet "${old_rev}..${new_rev}" -- 'shard.lock'; then - info "shard.lock did not change since $old_rev." +if git -C "$git_dir" diff-tree --quiet "v${old_version}..${new_tag}" -- 'shard.lock'; then + info "shard.lock did not change since v$old_version." else info "Updating shards.nix..." - crystal2nix -- "$git_dir/shard.lock" # argv's index seems broken + (cd "$git_dir" && crystal2nix) + mv "$git_dir/shards.nix" . fi - -git commit --verbose --message "$commit_msg" -- versions.json shards.nix diff --git a/pkgs/servers/invidious/versions.json b/pkgs/servers/invidious/versions.json index 16b0b50a8f6e..f6931c5fcd8d 100644 --- a/pkgs/servers/invidious/versions.json +++ b/pkgs/servers/invidious/versions.json @@ -1,8 +1,7 @@ { "invidious": { - "rev": "b673695aa2704b880562399ac78659ad23b7940d", - "hash": "sha256-2vYCQNAf+o1Z2HFMk4sIlKNBFAsiLZe0Iw34oThC2Vs=", - "version": "0.20.1-unstable-2024-04-10" + "hash": "sha256-YZ+uhn1ESuRTZxAMoxKCpxEaUfeCUqOrSr3LkdbrTkU=", + "version": "2.20240427" }, "videojs": { "hash": "sha256-jED3zsDkPN8i6GhBBJwnsHujbuwlHdsVpVqa1/pzSH4=" diff --git a/pkgs/servers/invidious/videojs.nix b/pkgs/servers/invidious/videojs.nix index 5b89e5bd3279..35ad0b1f0655 100644 --- a/pkgs/servers/invidious/videojs.nix +++ b/pkgs/servers/invidious/videojs.nix @@ -14,5 +14,5 @@ stdenvNoCC.mkDerivation { outputHashAlgo = "sha256"; outputHashMode = "recursive"; - outputHash = "sha256-jED3zsDkPN8i6GhBBJwnsHujbuwlHdsVpVqa1/pzSH4="; + outputHash = versions.videojs.hash; }