v2ray-rules-dat: use finalAttrs; modernize; 202606122311 -> 202606172318 (#532885)
This commit is contained in:
@@ -1,37 +1,44 @@
|
||||
{
|
||||
lib,
|
||||
stdenvNoCC,
|
||||
fetchurl,
|
||||
lib,
|
||||
}:
|
||||
let
|
||||
version = "202606122311";
|
||||
|
||||
geoipDat = fetchurl {
|
||||
url = "https://github.com/Loyalsoldier/v2ray-rules-dat/releases/download/${version}/geoip.dat";
|
||||
hash = "sha256-iGGpeUaWtIH7AEPueCssQOgL/Ia7nkLFvWnAj1SDsbU=";
|
||||
};
|
||||
|
||||
geositeDat = fetchurl {
|
||||
url = "https://github.com/Loyalsoldier/v2ray-rules-dat/releases/download/${version}/geosite.dat";
|
||||
hash = "sha256-/c/3OjfALveNnHS9NxonTeOiZyud6U/X4WHrGZSOs7Q=";
|
||||
};
|
||||
in
|
||||
stdenvNoCC.mkDerivation {
|
||||
stdenvNoCC.mkDerivation (finalAttrs: {
|
||||
pname = "v2ray-rules-dat";
|
||||
inherit version;
|
||||
version = "202606172318";
|
||||
|
||||
__structuredAttrs = true;
|
||||
strictDeps = true;
|
||||
|
||||
src = null;
|
||||
dontUnpack = true;
|
||||
|
||||
installPhase = ''
|
||||
install -Dm444 ${geoipDat} $out/share/v2ray/geoip.dat
|
||||
install -Dm444 ${geositeDat} $out/share/v2ray/geosite.dat
|
||||
runHook preInstall
|
||||
|
||||
install -Dm444 ${finalAttrs.passthru.geoipDat} $out/share/v2ray/geoip.dat
|
||||
install -Dm444 ${finalAttrs.passthru.geositeDat} $out/share/v2ray/geosite.dat
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
passthru = {
|
||||
geoipDat = fetchurl {
|
||||
url = "https://github.com/Loyalsoldier/v2ray-rules-dat/releases/download/${finalAttrs.version}/geoip.dat";
|
||||
hash = "sha256-iGGpeUaWtIH7AEPueCssQOgL/Ia7nkLFvWnAj1SDsbU=";
|
||||
};
|
||||
geositeDat = fetchurl {
|
||||
url = "https://github.com/Loyalsoldier/v2ray-rules-dat/releases/download/${finalAttrs.version}/geosite.dat";
|
||||
hash = "sha256-DEhEZP7ijNudb6qhIArpRhUqzEzmG0OxJaoBuMFVacM=";
|
||||
};
|
||||
updateScript = ./update.sh;
|
||||
};
|
||||
|
||||
meta = {
|
||||
description = "Enhanced edition of V2Ray rules dat files";
|
||||
homepage = "https://github.com/Loyalsoldier/v2ray-rules-dat";
|
||||
license = lib.licenses.gpl3;
|
||||
changelog = "https://github.com/Loyalsoldier/v2ray-rules-dat/releases/tag/${finalAttrs.version}";
|
||||
license = lib.licenses.gpl3Only;
|
||||
maintainers = with lib.maintainers; [ nix-julia ];
|
||||
};
|
||||
}
|
||||
})
|
||||
|
||||
Executable
+35
@@ -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
|
||||
Reference in New Issue
Block a user