Skip to content

Commit

Permalink
alist: add update.nix (#358335)
Browse files Browse the repository at this point in the history
  • Loading branch information
jian-lin authored Jan 28, 2025
2 parents cbabad5 + 6701551 commit bf97db9
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkgs/by-name/al/alist/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
stdenv,
installShellFiles,
versionCheckHook,
callPackage,
}:
buildGoModule rec {
pname = "alist";
Expand Down Expand Up @@ -88,6 +89,10 @@ buildGoModule rec {
versionCheckHook
];

passthru = {
updateScript = lib.getExe (callPackage ./update.nix { });
};

meta = {
description = "File list/WebDAV program that supports multiple storages";
homepage = "https://github.com/alist-org/alist";
Expand Down
43 changes: 43 additions & 0 deletions pkgs/by-name/al/alist/update.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
writeShellApplication,
nix,
nix-update,
curl,
jq,
common-updater-scripts,
}:

writeShellApplication {
name = "update-alist";
runtimeInputs = [
curl
jq
nix
common-updater-scripts
nix-update
];

text = ''
# get old info
oldVersion=$(nix-instantiate --eval --strict -A "alist.version" | jq -e -r)
get_latest_release() {
local repo=$1
curl --fail ''${GITHUB_TOKEN:+ -H "Authorization: bearer $GITHUB_TOKEN"} \
-s "https://api.github.com/repos/AlistGo/$repo/releases/latest" | jq -r ".tag_name"
}
version=$(get_latest_release "alist")
version="''${version#v}"
webVersion=$(get_latest_release "alist-web")
if [[ "$oldVersion" == "$version" ]]; then
echo "Already up to date!"
exit 0
fi
update-source-version alist "$webVersion" --source-key=web --version-key=webVersion
nix-update alist --version="$version"
'';
}

0 comments on commit bf97db9

Please sign in to comment.