Skip to content

Commit 56627a7

Browse files
author
nayeko
authored
flclash: add update script
1 parent 3172620 commit 56627a7

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

pkgs/by-name/fl/flclash/package.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ flutter324.buildFlutterApplication {
9696
install -Dm644 ./assets/images/icon.png $out/share/pixmaps/flclash.png
9797
'';
9898

99+
passthru.updateScript = ./update.sh;
100+
99101
meta = {
100102
description = "Multi-platform proxy client based on ClashMeta, simple and easy to use, open-source and ad-free";
101103
homepage = "https://github.com/chen08209/FlClash";

pkgs/by-name/fl/flclash/update.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env nix-shell
2+
#!nix-shell -I nixpkgs=./. -i bash -p curl gnused jq yq nix bash coreutils nix-update
3+
4+
set -eou pipefail
5+
6+
ROOT="$(dirname "$(readlink -f "$0")")"
7+
8+
latestTag=$(curl ${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} -sL https://api.github.com/repos/chen08209/FlClash/releases/latest | jq --raw-output .tag_name)
9+
latestVersion=$(echo "$latestTag" | sed 's/^v//')
10+
11+
currentVersion=$(nix-instantiate --eval -E "with import ./. {}; flclash.version or (lib.getVersion flclash)" | tr -d '"')
12+
13+
if [[ "$currentVersion" == "$latestVersion" ]]; then
14+
echo "package is up-to-date: $currentVersion"
15+
exit 0
16+
fi
17+
18+
nix-update --subpackage libclash flclash
19+
20+
curl https://raw.githubusercontent.com/chen08209/FlClash/${latestTag}/pubspec.lock | yq . >$ROOT/pubspec.lock.json

0 commit comments

Comments
 (0)