alist: add update.nix (#358335)

This commit is contained in:
Lin Jian
2025-01-28 23:18:48 +08:00
committed by GitHub
2 changed files with 48 additions and 0 deletions
+5
View File
@@ -7,6 +7,7 @@
stdenv,
installShellFiles,
versionCheckHook,
callPackage,
}:
buildGoModule rec {
pname = "alist";
@@ -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";
+43
View File
@@ -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"
'';
}