qq: add update script

This commit is contained in:
Deadbeef 2023-07-25 01:18:12 +08:00
parent 42c4d51f91
commit e286ed3aed
3 changed files with 48 additions and 7 deletions

View File

@ -23,23 +23,23 @@
}:
let
version = "3.2.1-17153";
_hash = "b69de82d";
sources = import ./sources.nix;
srcs = {
x86_64-linux = fetchurl {
url = "https://dldir1.qq.com/qqfile/qq/QQNT/${_hash}/linuxqq_${version}_amd64.deb";
hash = "sha256-+GjTjv0K2vnlkb46KhMvRRFWuIEBz23Lg3QhiA7QzkA=";
url = "https://dldir1.qq.com/qqfile/qq/QQNT/${sources.urlhash}/linuxqq_${sources.version}_amd64.deb";
hash = sources.amd64_hash;
};
aarch64-linux = fetchurl {
url = "https://dldir1.qq.com/qqfile/qq/QQNT/${_hash}/linuxqq_${version}_arm64.deb";
hash = "sha256-BtmmVpKZF15aU7RRmXl9g5leg2jz5sT4vYXluq9aIYk=";
url = "https://dldir1.qq.com/qqfile/qq/QQNT/${sources.urlhash}/linuxqq_${sources.version}_arm64.deb";
hash = sources.arm64_hash;
};
};
src = srcs.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
in
stdenv.mkDerivation {
pname = "qq";
inherit version src;
version = sources.version;
inherit src;
nativeBuildInputs = [
autoPatchelfHook
@ -98,6 +98,8 @@ stdenv.mkDerivation {
)
'';
passthru.updateScript = ./update.sh;
meta = with lib; {
homepage = "https://im.qq.com/linuxqq/";
description = "Messaging app";

View File

@ -0,0 +1,8 @@
# Generated by ./update.sh - do not update manually!
# Last updated: 2023-09-26
{
version = "3.2.1-17153";
urlhash = "b69de82d";
arm64_hash = "sha256-BtmmVpKZF15aU7RRmXl9g5leg2jz5sT4vYXluq9aIYk=";
amd64_hash = "sha256-+GjTjv0K2vnlkb46KhMvRRFWuIEBz23Lg3QhiA7QzkA=";
}

View File

@ -0,0 +1,31 @@
#! /usr/bin/env nix-shell
#! nix-shell -i bash --pure --keep GITHUB_TOKEN -p nix git curl cacert nix-prefetch-git jq
set -euo pipefail
cd $(readlink -e $(dirname "${BASH_SOURCE[0]}"))
payload=$(curl https://im.qq.com/rainbow/linuxQQDownload | grep -oP "var params= \K\{.*\}(?=;)")
amd64_url=$(jq -r .x64DownloadUrl.deb <<< "$payload")
arm64_url=$(jq -r .armDownloadUrl.deb <<< "$payload")
urlhash=$(grep -oP "(?<=QQNT/)[a-e0-9]+(?=/linuxqq)" <<< "$amd64_url")
version=$(grep -oP "(?<=/linuxqq_).*(?=_amd64.deb)" <<< "$amd64_url")
amd64_hash=$(nix-prefetch-url $amd64_url)
arm64_hash=$(nix-prefetch-url $arm64_url)
# use friendlier hashes
amd64_hash=$(nix hash to-sri --type sha256 "$amd64_hash")
arm64_hash=$(nix hash to-sri --type sha256 "$arm64_hash")
cat >sources.nix <<EOF
# Generated by ./update.sh - do not update manually!
# Last updated: $(date +%F)
{
version = "$version";
urlhash = "$urlhash";
arm64_hash = "$arm64_hash";
amd64_hash = "$amd64_hash";
}
EOF