From 867a336e0cbb260607394f457be7e331099b7a1c Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Sat, 27 Apr 2024 00:54:27 +0200 Subject: [PATCH 1/5] invidious: 0.20.1-unstable-2024-04-10 -> 2.20240427 Changelog: https://github.com/iv-org/invidious/releases/tag/v2.20240427 --- pkgs/servers/invidious/default.nix | 23 +++++++++++++---------- pkgs/servers/invidious/videojs.nix | 2 +- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/pkgs/servers/invidious/default.nix b/pkgs/servers/invidious/default.nix index 8cf00ab60a60..cf2de4c5a94d 100644 --- a/pkgs/servers/invidious/default.nix +++ b/pkgs/servers/invidious/default.nix @@ -16,14 +16,17 @@ let in crystal.buildCrystalPackage rec { pname = "invidious"; - inherit (versions.invidious) version; + version = "2.20240427"; + # inherit (versions.invidious) version; src = fetchFromGitea { domain = "gitea.invidious.io"; owner = "iv-org"; repo = pname; fetchSubmodules = true; - inherit (versions.invidious) rev hash; + rev = "v${version}"; + hash = "sha256-YZ+uhn1ESuRTZxAMoxKCpxEaUfeCUqOrSr3LkdbrTkU="; + # inherit (versions.invidious) rev hash; }; postPatch = @@ -43,23 +46,23 @@ crystal.buildCrystalPackage rec { # Use the version metadata from the derivation instead of using git at # build-time substituteInPlace src/invidious.cr \ - --replace ${lib.escapeShellArg branchTemplate} '"master"' \ - --replace ${lib.escapeShellArg commitTemplate} '"${lib.substring 0 7 versions.invidious.rev}"' \ - --replace ${lib.escapeShellArg versionTemplate} '"${lib.concatStringsSep "." (lib.drop 2 (lib.splitString "-" version))}"' \ - --replace ${lib.escapeShellArg assetCommitTemplate} '"${lib.substring 0 7 versions.invidious.rev}"' + --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}"' # Patch the assets and locales paths to be absolute substituteInPlace src/invidious.cr \ - --replace 'public_folder "assets"' 'public_folder "${placeholder "out"}/share/invidious/assets"' + --replace-fail 'public_folder "assets"' 'public_folder "${placeholder "out"}/share/invidious/assets"' substituteInPlace src/invidious/helpers/i18n.cr \ - --replace 'File.read("locales/' 'File.read("${placeholder "out"}/share/invidious/locales/' + --replace-fail 'File.read("locales/' 'File.read("${placeholder "out"}/share/invidious/locales/' # Reference sql initialisation/migration scripts by absolute path substituteInPlace src/invidious/database/base.cr \ - --replace 'config/sql' '${placeholder "out"}/share/invidious/config/sql' + --replace-fail 'config/sql' '${placeholder "out"}/share/invidious/config/sql' substituteInPlace src/invidious/user/captcha.cr \ - --replace 'Process.run(%(rsvg-convert' 'Process.run(%(${lib.getBin librsvg}/bin/rsvg-convert' + --replace-fail 'Process.run(%(rsvg-convert' 'Process.run(%(${lib.getBin librsvg}/bin/rsvg-convert' ''; nativeBuildInputs = [ pkg-config shards ]; diff --git a/pkgs/servers/invidious/videojs.nix b/pkgs/servers/invidious/videojs.nix index 35ad0b1f0655..5b89e5bd3279 100644 --- a/pkgs/servers/invidious/videojs.nix +++ b/pkgs/servers/invidious/videojs.nix @@ -14,5 +14,5 @@ stdenvNoCC.mkDerivation { outputHashAlgo = "sha256"; outputHashMode = "recursive"; - outputHash = versions.videojs.hash; + outputHash = "sha256-jED3zsDkPN8i6GhBBJwnsHujbuwlHdsVpVqa1/pzSH4="; } From 73584c2510d3044cc9e7997e75a5bdb1864da3b1 Mon Sep 17 00:00:00 2001 From: Sophie Tauchert Date: Mon, 29 Apr 2024 19:35:26 +0200 Subject: [PATCH 2/5] invidious: switch update script to use tagged releases --- pkgs/servers/invidious/default.nix | 6 ++---- pkgs/servers/invidious/update.sh | 27 +++++++++------------------ pkgs/servers/invidious/versions.json | 5 ++--- pkgs/servers/invidious/videojs.nix | 2 +- 4 files changed, 14 insertions(+), 26 deletions(-) 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; } From 9e0ab0983a910b9f2b2253cc5991cf89d7eebe9b Mon Sep 17 00:00:00 2001 From: Sophie Tauchert Date: Mon, 29 Apr 2024 20:00:20 +0200 Subject: [PATCH 3/5] 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=" From 69d88e341d62f9ff51cb1151c1c5e863227d5d26 Mon Sep 17 00:00:00 2001 From: Sophie Tauchert Date: Mon, 29 Apr 2024 20:09:38 +0200 Subject: [PATCH 4/5] invidious: make versions overridable --- pkgs/servers/invidious/default.nix | 25 ++++++++++++++++++------- pkgs/servers/invidious/videojs.nix | 12 ++++++++---- pkgs/top-level/all-packages.nix | 5 +---- 3 files changed, 27 insertions(+), 15 deletions(-) diff --git a/pkgs/servers/invidious/default.nix b/pkgs/servers/invidious/default.nix index 2c398e6bbbd2..b63e14e907c3 100644 --- a/pkgs/servers/invidious/default.nix +++ b/pkgs/servers/invidious/default.nix @@ -1,5 +1,15 @@ -{ lib, stdenv, crystal, fetchFromGitea, librsvg, pkg-config, libxml2, openssl, shards, sqlite, videojs, nixosTests }: -let +{ lib +, callPackage +, crystal +, fetchFromGitea +, librsvg +, pkg-config +, libxml2 +, openssl +, shards +, sqlite +, nixosTests + # All versions, revisions, and checksums are stored in ./versions.json. # The update process is the following: # * pick the latest tag @@ -9,10 +19,11 @@ let # but nix's sandboxing does not allow that) # * if shard.lock changed # * recreate shards.nix by running crystal2nix - # * update lsquic and boringssl if necessarry, lsquic.cr depends on - # the same version of lsquic and lsquic requires the boringssl - # commit mentioned in its README - versions = lib.importJSON ./versions.json; +, versions ? lib.importJSON ./versions.json +}: +let + # normally video.js is downloaded at build time + videojs = callPackage ./videojs.nix { inherit versions; }; in crystal.buildCrystalPackage rec { pname = "invidious"; @@ -23,7 +34,7 @@ crystal.buildCrystalPackage rec { owner = "iv-org"; repo = "invidious"; fetchSubmodules = true; - rev = "v${version}"; + rev = versions.invidious.rev or "v${version}"; inherit (versions.invidious) hash; }; diff --git a/pkgs/servers/invidious/videojs.nix b/pkgs/servers/invidious/videojs.nix index 35ad0b1f0655..dcd6e9e97cbf 100644 --- a/pkgs/servers/invidious/videojs.nix +++ b/pkgs/servers/invidious/videojs.nix @@ -1,8 +1,12 @@ -{ lib, stdenvNoCC, cacert, crystal, openssl, pkg-config, invidious }: +{ stdenvNoCC +, cacert +, crystal +, openssl +, pkg-config +, invidious +, versions +}: -let - versions = lib.importJSON ./versions.json; -in stdenvNoCC.mkDerivation { name = "videojs"; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index c0054b6f0a94..4f975e4a4e34 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -9258,10 +9258,7 @@ with pkgs; internetarchive = with python3Packages; toPythonApplication internetarchive; - invidious = callPackage ../servers/invidious { - # normally video.js is downloaded at build time - videojs = callPackage ../servers/invidious/videojs.nix { }; - }; + invidious = callPackage ../servers/invidious { }; invoice2data = callPackage ../tools/text/invoice2data { }; From c92f9f41f5c2fa52572c53889b9824266693d7b4 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Tue, 30 Apr 2024 00:09:06 +0200 Subject: [PATCH 5/5] invidious: add _999eagle, pbsds and GaetanLepage as maintainers --- pkgs/servers/invidious/default.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkgs/servers/invidious/default.nix b/pkgs/servers/invidious/default.nix index b63e14e907c3..716df1007831 100644 --- a/pkgs/servers/invidious/default.nix +++ b/pkgs/servers/invidious/default.nix @@ -124,6 +124,11 @@ crystal.buildCrystalPackage rec { mainProgram = "invidious"; homepage = "https://invidious.io/"; license = licenses.agpl3Plus; - maintainers = with maintainers; [ sbruder ]; + maintainers = with maintainers; [ + _999eagle + GaetanLepage + sbruder + pbsds + ]; }; }