mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-07-06 17:13:24 -05:00
v2ray-rules-dat: add updateScript
(cherry picked from commit c2d350a01f)
This commit is contained in:
parent
b0f28e8d48
commit
4088776d40
2 changed files with 36 additions and 0 deletions
|
|
@ -31,6 +31,7 @@ stdenvNoCC.mkDerivation (finalAttrs: {
|
|||
url = "https://github.com/Loyalsoldier/v2ray-rules-dat/releases/download/${finalAttrs.version}/geosite.dat";
|
||||
hash = "sha256-/c/3OjfALveNnHS9NxonTeOiZyud6U/X4WHrGZSOs7Q=";
|
||||
};
|
||||
updateScript = ./update.sh;
|
||||
};
|
||||
|
||||
meta = {
|
||||
|
|
|
|||
35
pkgs/by-name/v2/v2ray-rules-dat/update.sh
Executable file
35
pkgs/by-name/v2/v2ray-rules-dat/update.sh
Executable file
|
|
@ -0,0 +1,35 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i bash -p curl jq nix common-updater-scripts
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
version="$(
|
||||
curl -fsSL ${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} "https://api.github.com/repos/Loyalsoldier/v2ray-rules-dat/releases/latest" \
|
||||
| jq -r .tag_name
|
||||
)"
|
||||
|
||||
if [[ "$UPDATE_NIX_OLD_VERSION" == "$version" ]]; then
|
||||
echo "Already up to date!"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
prefetch_hash() {
|
||||
local name="$1"
|
||||
nix --extra-experimental-features nix-command \
|
||||
store prefetch-file \
|
||||
--json \
|
||||
--hash-type sha256 \
|
||||
"https://github.com/Loyalsoldier/v2ray-rules-dat/releases/download/$version/$name" \
|
||||
| jq -r .hash
|
||||
}
|
||||
|
||||
geoip_hash="$(prefetch_hash geoip.dat)"
|
||||
geosite_hash="$(prefetch_hash geosite.dat)"
|
||||
|
||||
update-source-version "v2ray-rules-dat" "$version" "$geoip_hash" \
|
||||
--source-key=passthru.geoipDat \
|
||||
--ignore-same-version --ignore-same-hash
|
||||
|
||||
update-source-version "v2ray-rules-dat" "$version" "$geosite_hash" \
|
||||
--source-key=passthru.geositeDat \
|
||||
--ignore-same-version --ignore-same-hash
|
||||
Loading…
Add table
Add a link
Reference in a new issue