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