Merge pull request #307083 from GaetanLepage/invidious
invidious: 0.20.1-unstable-2024-04-10 -> 2.20240427
This commit is contained in:
commit
e11ca48735
@ -1,18 +1,29 @@
|
|||||||
{ lib, stdenv, crystal, fetchFromGitea, librsvg, pkg-config, libxml2, openssl, shards, sqlite, videojs, nixosTests }:
|
{ lib
|
||||||
let
|
, callPackage
|
||||||
|
, crystal
|
||||||
|
, fetchFromGitea
|
||||||
|
, librsvg
|
||||||
|
, pkg-config
|
||||||
|
, libxml2
|
||||||
|
, openssl
|
||||||
|
, shards
|
||||||
|
, sqlite
|
||||||
|
, nixosTests
|
||||||
|
|
||||||
# All versions, revisions, and checksums are stored in ./versions.json.
|
# All versions, revisions, and checksums are stored in ./versions.json.
|
||||||
# The update process is the following:
|
# The update process is the following:
|
||||||
# * pick the latest commit
|
# * pick the latest tag
|
||||||
# * update .invidious.rev, .invidious.version, and .invidious.hash
|
# * update .invidious.version, .invidious.date, .invidious.commit and .invidious.hash
|
||||||
# * prefetch the videojs dependencies with scripts/fetch-player-dependencies.cr
|
# * prefetch the videojs dependencies with scripts/fetch-player-dependencies.cr
|
||||||
# and update .videojs.hash (they are normally fetched during build
|
# and update .videojs.hash (they are normally fetched during build
|
||||||
# but nix's sandboxing does not allow that)
|
# but nix's sandboxing does not allow that)
|
||||||
# * if shard.lock changed
|
# * if shard.lock changed
|
||||||
# * recreate shards.nix by running crystal2nix
|
# * recreate shards.nix by running crystal2nix
|
||||||
# * update lsquic and boringssl if necessarry, lsquic.cr depends on
|
, versions ? lib.importJSON ./versions.json
|
||||||
# the same version of lsquic and lsquic requires the boringssl
|
}:
|
||||||
# commit mentioned in its README
|
let
|
||||||
versions = lib.importJSON ./versions.json;
|
# normally video.js is downloaded at build time
|
||||||
|
videojs = callPackage ./videojs.nix { inherit versions; };
|
||||||
in
|
in
|
||||||
crystal.buildCrystalPackage rec {
|
crystal.buildCrystalPackage rec {
|
||||||
pname = "invidious";
|
pname = "invidious";
|
||||||
@ -21,9 +32,10 @@ crystal.buildCrystalPackage rec {
|
|||||||
src = fetchFromGitea {
|
src = fetchFromGitea {
|
||||||
domain = "gitea.invidious.io";
|
domain = "gitea.invidious.io";
|
||||||
owner = "iv-org";
|
owner = "iv-org";
|
||||||
repo = pname;
|
repo = "invidious";
|
||||||
fetchSubmodules = true;
|
fetchSubmodules = true;
|
||||||
inherit (versions.invidious) rev hash;
|
rev = versions.invidious.rev or "v${version}";
|
||||||
|
inherit (versions.invidious) hash;
|
||||||
};
|
};
|
||||||
|
|
||||||
postPatch =
|
postPatch =
|
||||||
@ -36,6 +48,8 @@ crystal.buildCrystalPackage rec {
|
|||||||
# This always uses the latest commit which invalidates the cache even if
|
# This always uses the latest commit which invalidates the cache even if
|
||||||
# the assets were not changed
|
# the assets were not changed
|
||||||
assetCommitTemplate = ''{{ "#{`git rev-list HEAD --max-count=1 --abbrev-commit -- assets`.strip}" }}'';
|
assetCommitTemplate = ''{{ "#{`git rev-list HEAD --max-count=1 --abbrev-commit -- assets`.strip}" }}'';
|
||||||
|
|
||||||
|
inherit (versions.invidious) commit date;
|
||||||
in
|
in
|
||||||
''
|
''
|
||||||
for d in ${videojs}/*; do ln -s "$d" assets/videojs; done
|
for d in ${videojs}/*; do ln -s "$d" assets/videojs; done
|
||||||
@ -43,23 +57,23 @@ crystal.buildCrystalPackage rec {
|
|||||||
# Use the version metadata from the derivation instead of using git at
|
# Use the version metadata from the derivation instead of using git at
|
||||||
# build-time
|
# build-time
|
||||||
substituteInPlace src/invidious.cr \
|
substituteInPlace src/invidious.cr \
|
||||||
--replace ${lib.escapeShellArg branchTemplate} '"master"' \
|
--replace-fail ${lib.escapeShellArg branchTemplate} '"master"' \
|
||||||
--replace ${lib.escapeShellArg commitTemplate} '"${lib.substring 0 7 versions.invidious.rev}"' \
|
--replace-fail ${lib.escapeShellArg commitTemplate} '"${commit}"' \
|
||||||
--replace ${lib.escapeShellArg versionTemplate} '"${lib.concatStringsSep "." (lib.drop 2 (lib.splitString "-" version))}"' \
|
--replace-fail ${lib.escapeShellArg versionTemplate} '"${date}"' \
|
||||||
--replace ${lib.escapeShellArg assetCommitTemplate} '"${lib.substring 0 7 versions.invidious.rev}"'
|
--replace-fail ${lib.escapeShellArg assetCommitTemplate} '"${commit}"'
|
||||||
|
|
||||||
# Patch the assets and locales paths to be absolute
|
# Patch the assets and locales paths to be absolute
|
||||||
substituteInPlace src/invidious.cr \
|
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 \
|
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
|
# Reference sql initialisation/migration scripts by absolute path
|
||||||
substituteInPlace src/invidious/database/base.cr \
|
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 \
|
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 ];
|
nativeBuildInputs = [ pkg-config shards ];
|
||||||
@ -110,6 +124,11 @@ crystal.buildCrystalPackage rec {
|
|||||||
mainProgram = "invidious";
|
mainProgram = "invidious";
|
||||||
homepage = "https://invidious.io/";
|
homepage = "https://invidious.io/";
|
||||||
license = licenses.agpl3Plus;
|
license = licenses.agpl3Plus;
|
||||||
maintainers = with maintainers; [ sbruder ];
|
maintainers = with maintainers; [
|
||||||
|
_999eagle
|
||||||
|
GaetanLepage
|
||||||
|
sbruder
|
||||||
|
pbsds
|
||||||
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env nix-shell
|
#!/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_url='https://github.com/iv-org/invidious.git'
|
||||||
git_branch='master'
|
git_branch='master'
|
||||||
git_dir='/var/tmp/invidious.git'
|
git_dir='/var/tmp/invidious.git'
|
||||||
@ -26,7 +26,6 @@ json_set() {
|
|||||||
jq --arg x "$2" "$1 = \$x" < 'versions.json' | sponge 'versions.json'
|
jq --arg x "$2" "$1 = \$x" < 'versions.json' | sponge 'versions.json'
|
||||||
}
|
}
|
||||||
|
|
||||||
old_rev=$(json_get '.invidious.rev')
|
|
||||||
old_version=$(json_get '.invidious.version')
|
old_version=$(json_get '.invidious.version')
|
||||||
today=$(LANG=C date -u +'%Y-%m-%d')
|
today=$(LANG=C date -u +'%Y-%m-%d')
|
||||||
|
|
||||||
@ -37,38 +36,35 @@ if [ ! -d "$git_dir" ]; then
|
|||||||
fi
|
fi
|
||||||
git -C "$git_dir" fetch origin --tags "$git_branch"
|
git -C "$git_dir" fetch origin --tags "$git_branch"
|
||||||
|
|
||||||
# use latest commit before today, we should not call the version *today*
|
new_tag="$(git -C "$git_dir" ls-remote --tags --sort=committerdate origin | head -n1 | grep -Po '(?<=refs/tags/).*')"
|
||||||
# because there might still be commits coming
|
new_version="${new_tag#v}"
|
||||||
# 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"
|
|
||||||
|
|
||||||
if [ "$new_rev" = "$old_rev" ]; then
|
if [ "$new_version" = "$old_version" ]; then
|
||||||
info "$pkg is up-to-date."
|
info "$pkg is up-to-date."
|
||||||
exit
|
exit
|
||||||
fi
|
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"
|
json_set '.invidious.version' "$new_version"
|
||||||
json_set '.invidious.rev' "$new_rev"
|
|
||||||
new_hash=$(nix-prefetch -I 'nixpkgs=../../..' "$pkg")
|
new_hash=$(nix-prefetch -I 'nixpkgs=../../..' "$pkg")
|
||||||
json_set '.invidious.hash' "$new_hash"
|
json_set '.invidious.hash' "$new_hash"
|
||||||
commit_msg="$pkg: $old_version -> $new_version"
|
|
||||||
|
|
||||||
# fetch video.js dependencies
|
# fetch video.js dependencies
|
||||||
info "Running scripts/fetch-player-dependencies.cr..."
|
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)
|
(cd "$git_dir" && crystal run scripts/fetch-player-dependencies.cr -- --minified)
|
||||||
rm -f "$git_dir/assets/videojs/.gitignore"
|
rm -f "$git_dir/assets/videojs/.gitignore"
|
||||||
videojs_new_hash=$(nix-hash --type sha256 --sri "$git_dir/assets/videojs")
|
videojs_new_hash=$(nix-hash --type sha256 --sri "$git_dir/assets/videojs")
|
||||||
json_set '.videojs.hash' "$videojs_new_hash"
|
json_set '.videojs.hash' "$videojs_new_hash"
|
||||||
|
|
||||||
if git -C "$git_dir" diff-tree --quiet "${old_rev}..${new_rev}" -- 'shard.lock'; then
|
if git -C "$git_dir" diff-tree --quiet "v${old_version}..${new_tag}" -- 'shard.lock'; then
|
||||||
info "shard.lock did not change since $old_rev."
|
info "shard.lock did not change since v$old_version."
|
||||||
else
|
else
|
||||||
info "Updating shards.nix..."
|
info "Updating shards.nix..."
|
||||||
crystal2nix -- "$git_dir/shard.lock" # argv's index seems broken
|
(cd "$git_dir" && crystal2nix)
|
||||||
|
mv "$git_dir/shards.nix" .
|
||||||
fi
|
fi
|
||||||
|
|
||||||
git commit --verbose --message "$commit_msg" -- versions.json shards.nix
|
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
{
|
{
|
||||||
"invidious": {
|
"invidious": {
|
||||||
"rev": "b673695aa2704b880562399ac78659ad23b7940d",
|
"hash": "sha256-YZ+uhn1ESuRTZxAMoxKCpxEaUfeCUqOrSr3LkdbrTkU=",
|
||||||
"hash": "sha256-2vYCQNAf+o1Z2HFMk4sIlKNBFAsiLZe0Iw34oThC2Vs=",
|
"version": "2.20240427",
|
||||||
"version": "0.20.1-unstable-2024-04-10"
|
"date": "2024.04.27",
|
||||||
|
"commit": "eda7444c"
|
||||||
},
|
},
|
||||||
"videojs": {
|
"videojs": {
|
||||||
"hash": "sha256-jED3zsDkPN8i6GhBBJwnsHujbuwlHdsVpVqa1/pzSH4="
|
"hash": "sha256-jED3zsDkPN8i6GhBBJwnsHujbuwlHdsVpVqa1/pzSH4="
|
||||||
|
@ -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 {
|
stdenvNoCC.mkDerivation {
|
||||||
name = "videojs";
|
name = "videojs";
|
||||||
|
|
||||||
|
@ -9257,10 +9257,7 @@ with pkgs;
|
|||||||
|
|
||||||
internetarchive = with python3Packages; toPythonApplication internetarchive;
|
internetarchive = with python3Packages; toPythonApplication internetarchive;
|
||||||
|
|
||||||
invidious = callPackage ../servers/invidious {
|
invidious = callPackage ../servers/invidious { };
|
||||||
# normally video.js is downloaded at build time
|
|
||||||
videojs = callPackage ../servers/invidious/videojs.nix { };
|
|
||||||
};
|
|
||||||
|
|
||||||
invoice2data = callPackage ../tools/text/invoice2data { };
|
invoice2data = callPackage ../tools/text/invoice2data { };
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user