From 9e0ab0983a910b9f2b2253cc5991cf89d7eebe9b Mon Sep 17 00:00:00 2001 From: Sophie Tauchert Date: Mon, 29 Apr 2024 20:00:20 +0200 Subject: [PATCH] invidious: determine version string components in update script --- pkgs/servers/invidious/default.nix | 14 ++++++++------ pkgs/servers/invidious/update.sh | 5 +++++ pkgs/servers/invidious/versions.json | 4 +++- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/pkgs/servers/invidious/default.nix b/pkgs/servers/invidious/default.nix index b02fccec080c..2c398e6bbbd2 100644 --- a/pkgs/servers/invidious/default.nix +++ b/pkgs/servers/invidious/default.nix @@ -2,8 +2,8 @@ let # All versions, revisions, and checksums are stored in ./versions.json. # The update process is the following: - # * pick the latest commit - # * update .invidious.rev, .invidious.version, and .invidious.hash + # * pick the latest tag + # * update .invidious.version, .invidious.date, .invidious.commit and .invidious.hash # * prefetch the videojs dependencies with scripts/fetch-player-dependencies.cr # and update .videojs.hash (they are normally fetched during build # but nix's sandboxing does not allow that) @@ -21,7 +21,7 @@ crystal.buildCrystalPackage rec { src = fetchFromGitea { domain = "gitea.invidious.io"; owner = "iv-org"; - repo = pname; + repo = "invidious"; fetchSubmodules = true; rev = "v${version}"; inherit (versions.invidious) hash; @@ -37,6 +37,8 @@ crystal.buildCrystalPackage rec { # This always uses the latest commit which invalidates the cache even if # the assets were not changed assetCommitTemplate = ''{{ "#{`git rev-list HEAD --max-count=1 --abbrev-commit -- assets`.strip}" }}''; + + inherit (versions.invidious) commit date; in '' for d in ${videojs}/*; do ln -s "$d" assets/videojs; done @@ -45,9 +47,9 @@ crystal.buildCrystalPackage rec { # build-time substituteInPlace src/invidious.cr \ --replace-fail ${lib.escapeShellArg branchTemplate} '"master"' \ - --replace-fail ${lib.escapeShellArg commitTemplate} '"${lib.substring 0 7 versions.invidious.rev}"' \ - --replace-fail ${lib.escapeShellArg versionTemplate} '"${lib.concatStringsSep "." (lib.drop 2 (lib.splitString "-" version))}"' \ - --replace-fail ${lib.escapeShellArg assetCommitTemplate} '"${lib.substring 0 7 versions.invidious.rev}"' + --replace-fail ${lib.escapeShellArg commitTemplate} '"${commit}"' \ + --replace-fail ${lib.escapeShellArg versionTemplate} '"${date}"' \ + --replace-fail ${lib.escapeShellArg assetCommitTemplate} '"${commit}"' # Patch the assets and locales paths to be absolute substituteInPlace src/invidious.cr \ diff --git a/pkgs/servers/invidious/update.sh b/pkgs/servers/invidious/update.sh index 64911449630c..2ba5c3452c6c 100755 --- a/pkgs/servers/invidious/update.sh +++ b/pkgs/servers/invidious/update.sh @@ -44,7 +44,12 @@ if [ "$new_version" = "$old_version" ]; then exit fi +commit="$(git -C "$git_dir" rev-list "$new_tag" --max-count=1 --abbrev-commit)" +date="$(git -C "$git_dir" log -1 --format=%cd --date=format:%Y.%m.%d)" +json_set '.invidious.date' "$date" +json_set '.invidious.commit' "$commit" json_set '.invidious.version' "$new_version" + new_hash=$(nix-prefetch -I 'nixpkgs=../../..' "$pkg") json_set '.invidious.hash' "$new_hash" diff --git a/pkgs/servers/invidious/versions.json b/pkgs/servers/invidious/versions.json index f6931c5fcd8d..35a6f77b84b6 100644 --- a/pkgs/servers/invidious/versions.json +++ b/pkgs/servers/invidious/versions.json @@ -1,7 +1,9 @@ { "invidious": { "hash": "sha256-YZ+uhn1ESuRTZxAMoxKCpxEaUfeCUqOrSr3LkdbrTkU=", - "version": "2.20240427" + "version": "2.20240427", + "date": "2024.04.27", + "commit": "eda7444c" }, "videojs": { "hash": "sha256-jED3zsDkPN8i6GhBBJwnsHujbuwlHdsVpVqa1/pzSH4="