nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 writeShellApplication,
3 nix,
4 nix-update,
5 curl,
6 jq,
7 common-updater-scripts,
8}:
9
10writeShellApplication {
11 name = "update-alist";
12 runtimeInputs = [
13 curl
14 jq
15 nix
16 common-updater-scripts
17 nix-update
18 ];
19
20 text = ''
21 # get old info
22 oldVersion=$(nix-instantiate --eval --strict -A "alist.version" | jq -e -r)
23
24 get_latest_release() {
25 local repo=$1
26 curl --fail ''${GITHUB_TOKEN:+ -H "Authorization: bearer $GITHUB_TOKEN"} \
27 -s "https://api.github.com/repos/AlistGo/$repo/releases/latest" | jq -r ".tag_name"
28 }
29
30 version=$(get_latest_release "alist")
31 version="''${version#v}"
32 webVersion=$(get_latest_release "alist-web")
33
34 if [[ "$oldVersion" == "$version" ]]; then
35 echo "Already up to date!"
36 exit 0
37 fi
38
39 update-source-version alist "$webVersion" --source-key=web --version-key=webVersion
40
41 nix-update alist --version="$version"
42 '';
43}