lol

invidious: move to by-name

+71 -73
+71
pkgs/by-name/in/invidious/update.sh
··· 1 + #!/usr/bin/env nix-shell 2 + #!nix-shell -i bash -p curl crystal crystal2nix jq git moreutils nix nix-prefetch pkg-config pcre gnugrep 3 + git_url='https://github.com/iv-org/invidious.git' 4 + git_branch='master' 5 + git_dir='/var/tmp/invidious.git' 6 + pkg='invidious' 7 + 8 + set -euo pipefail 9 + 10 + cd "$(dirname "${BASH_SOURCE[0]}")" 11 + 12 + info() { 13 + if [ -t 2 ]; then 14 + set -- '\033[32m%s\033[39m\n' "$@" 15 + else 16 + set -- '%s\n' "$@" 17 + fi 18 + printf "$@" >&2 19 + } 20 + 21 + json_get() { 22 + jq -r "$1" < 'versions.json' 23 + } 24 + 25 + json_set() { 26 + jq --arg x "$2" "$1 = \$x" < 'versions.json' | sponge 'versions.json' 27 + } 28 + 29 + old_version=$(json_get '.invidious.version') 30 + today=$(LANG=C date -u +'%Y-%m-%d') 31 + 32 + info "fetching $git_url..." 33 + if [ ! -d "$git_dir" ]; then 34 + git init --initial-branch="$git_branch" "$git_dir" 35 + git -C "$git_dir" remote add origin "$git_url" 36 + fi 37 + git -C "$git_dir" fetch origin --tags "$git_branch" 38 + 39 + new_tag="$(git -C "$git_dir" ls-remote --tags --sort=-committerdate origin | tail -n1 | grep -Po '(?<=refs/tags/).*')" 40 + new_version="${new_tag#v}" 41 + 42 + if [ "$new_version" = "$old_version" ]; then 43 + info "$pkg is up-to-date." 44 + exit 45 + fi 46 + 47 + info "updating to $new_tag" 48 + commit="$(git -C "$git_dir" rev-list "$new_tag" --max-count=1 --abbrev-commit)" 49 + date="$(git -C "$git_dir" log -1 --format=%cd --date=format:%Y.%m.%d "$commit")" 50 + json_set '.invidious.date' "$date" 51 + json_set '.invidious.commit' "$commit" 52 + json_set '.invidious.version' "$new_version" 53 + 54 + new_hash=$(nix-prefetch -I 'nixpkgs=../../../..' "$pkg") 55 + json_set '.invidious.hash' "$new_hash" 56 + 57 + # fetch video.js dependencies 58 + info "Running scripts/fetch-player-dependencies.cr..." 59 + git -C "$git_dir" reset --hard "$new_tag" 60 + (cd "$git_dir" && crystal run scripts/fetch-player-dependencies.cr -- --minified) 61 + rm -f "$git_dir/assets/videojs/.gitignore" 62 + videojs_new_hash=$(nix-hash --type sha256 --sri "$git_dir/assets/videojs") 63 + json_set '.videojs.hash' "$videojs_new_hash" 64 + 65 + if git -C "$git_dir" diff-tree --quiet "v${old_version}..${new_tag}" -- 'shard.lock'; then 66 + info "shard.lock did not change since v$old_version." 67 + else 68 + info "Updating shards.nix..." 69 + (cd "$git_dir" && crystal2nix) 70 + mv "$git_dir/shards.nix" . 71 + fi
pkgs/servers/invidious/default.nix pkgs/by-name/in/invidious/package.nix
pkgs/servers/invidious/shards.nix pkgs/by-name/in/invidious/shards.nix
-71
pkgs/servers/invidious/update.sh
··· 1 - #!/usr/bin/env nix-shell 2 - #!nix-shell -i bash -p curl crystal crystal2nix jq git moreutils nix nix-prefetch pkg-config pcre gnugrep 3 - git_url='https://github.com/iv-org/invidious.git' 4 - git_branch='master' 5 - git_dir='/var/tmp/invidious.git' 6 - pkg='invidious' 7 - 8 - set -euo pipefail 9 - 10 - cd "$(dirname "${BASH_SOURCE[0]}")" 11 - 12 - info() { 13 - if [ -t 2 ]; then 14 - set -- '\033[32m%s\033[39m\n' "$@" 15 - else 16 - set -- '%s\n' "$@" 17 - fi 18 - printf "$@" >&2 19 - } 20 - 21 - json_get() { 22 - jq -r "$1" < 'versions.json' 23 - } 24 - 25 - json_set() { 26 - jq --arg x "$2" "$1 = \$x" < 'versions.json' | sponge 'versions.json' 27 - } 28 - 29 - old_version=$(json_get '.invidious.version') 30 - today=$(LANG=C date -u +'%Y-%m-%d') 31 - 32 - info "fetching $git_url..." 33 - if [ ! -d "$git_dir" ]; then 34 - git init --initial-branch="$git_branch" "$git_dir" 35 - git -C "$git_dir" remote add origin "$git_url" 36 - fi 37 - git -C "$git_dir" fetch origin --tags "$git_branch" 38 - 39 - new_tag="$(git -C "$git_dir" ls-remote --tags --sort=-committerdate origin | tail -n1 | grep -Po '(?<=refs/tags/).*')" 40 - new_version="${new_tag#v}" 41 - 42 - if [ "$new_version" = "$old_version" ]; then 43 - info "$pkg is up-to-date." 44 - exit 45 - fi 46 - 47 - info "updating to $new_tag" 48 - commit="$(git -C "$git_dir" rev-list "$new_tag" --max-count=1 --abbrev-commit)" 49 - date="$(git -C "$git_dir" log -1 --format=%cd --date=format:%Y.%m.%d "$commit")" 50 - json_set '.invidious.date' "$date" 51 - json_set '.invidious.commit' "$commit" 52 - json_set '.invidious.version' "$new_version" 53 - 54 - new_hash=$(nix-prefetch -I 'nixpkgs=../../..' "$pkg") 55 - json_set '.invidious.hash' "$new_hash" 56 - 57 - # fetch video.js dependencies 58 - info "Running scripts/fetch-player-dependencies.cr..." 59 - git -C "$git_dir" reset --hard "$new_tag" 60 - (cd "$git_dir" && crystal run scripts/fetch-player-dependencies.cr -- --minified) 61 - rm -f "$git_dir/assets/videojs/.gitignore" 62 - videojs_new_hash=$(nix-hash --type sha256 --sri "$git_dir/assets/videojs") 63 - json_set '.videojs.hash' "$videojs_new_hash" 64 - 65 - if git -C "$git_dir" diff-tree --quiet "v${old_version}..${new_tag}" -- 'shard.lock'; then 66 - info "shard.lock did not change since v$old_version." 67 - else 68 - info "Updating shards.nix..." 69 - (cd "$git_dir" && crystal2nix) 70 - mv "$git_dir/shards.nix" . 71 - fi
pkgs/servers/invidious/versions.json pkgs/by-name/in/invidious/versions.json
pkgs/servers/invidious/videojs.nix pkgs/by-name/in/invidious/videojs.nix
pkgs/servers/invidious/videojs.sh pkgs/by-name/in/invidious/videojs.sh
-2
pkgs/top-level/all-packages.nix
··· 3995 3995 3996 3996 internetarchive = with python3Packages; toPythonApplication internetarchive; 3997 3997 3998 - invidious = callPackage ../servers/invidious { }; 3999 - 4000 3998 iocextract = with python3Packages; toPythonApplication iocextract; 4001 3999 4002 4000 iocsearcher = with python3Packages; toPythonApplication iocsearcher;