wechat-uos: Fix download

This commit is contained in:
Bu Kun
2025-09-25 14:11:25 +08:00
parent b56976b4b1
commit fc63b9a0d4
3 changed files with 99 additions and 65 deletions
+71 -49
View File
@@ -45,6 +45,10 @@
libnotify,
buildFHSEnv,
writeShellScript,
runCommandLocal,
cacert,
coreutils,
curl,
}:
let
wechat-uos-env = stdenvNoCC.mkDerivation {
@@ -123,66 +127,84 @@ let
bzip2
];
sources = import ./sources.nix;
wechat =
let
sources = import ./sources.nix;
wechat = stdenvNoCC.mkDerivation rec {
pname = "wechat-uos";
version = sources.version;
pname = "wechat-uos";
version = sources.version;
fetch =
{
url,
hash,
}:
runCommandLocal "wechat-uos-${version}-src"
{
outputHashAlgo = "sha256";
outputHash = hash;
src =
{
x86_64-linux = fetchurl {
url = sources.amd64_url;
hash = sources.amd64_hash;
};
aarch64-linux = fetchurl {
url = sources.arm64_url;
hash = sources.arm64_hash;
};
loongarch64-linux = fetchurl {
url = sources.loongarch64_url;
hash = sources.loongarch64_hash;
};
}
.${stdenv.system} or (throw "${pname}-${version}: ${stdenv.system} is unsupported.");
nativeBuildInputs = [
curl
coreutils
];
nativeBuildInputs = [ dpkg ];
impureEnvVars = lib.fetchers.proxyImpureEnvVars;
SSL_CERT_FILE = "${cacert}/etc/ssl/certs/ca-bundle.crt";
}
''
curl -A "debian APT-HTTP/1.3 (1.6.11)" --retry 3 --retry-delay 3 -L "${url}" > $out
'';
unpackPhase = ''
runHook preUnpack
srcs = {
x86_64-linux = fetch sources.amd64;
aarch64-linux = fetch sources.arm64;
loongarch64-linux = fetch sources.loongarch64;
};
dpkg -x $src ./wechat-uos
src =
srcs.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
runHook postUnpack
'';
in
stdenvNoCC.mkDerivation {
inherit pname src version;
# Use ln for license to prevent being garbage collection
installPhase = ''
runHook preInstall
mkdir -p $out
nativeBuildInputs = [ dpkg ];
cp -r wechat-uos/* $out
unpackPhase = ''
runHook preUnpack
runHook postInstall
'';
dpkg -x $src ./wechat-uos
meta = with lib; {
description = "Messaging app";
homepage = "https://weixin.qq.com/";
license = licenses.unfree;
platforms = [
"x86_64-linux"
"aarch64-linux"
"loongarch64-linux"
];
sourceProvenance = with sourceTypes; [ binaryNativeCode ];
maintainers = with maintainers; [
pokon548
xddxdd
];
mainProgram = "wechat-uos";
runHook postUnpack
'';
# Use ln for license to prevent being garbage collection
installPhase = ''
runHook preInstall
mkdir -p $out
cp -r wechat-uos/* $out
runHook postInstall
'';
meta = with lib; {
description = "Messaging app";
homepage = "https://weixin.qq.com/";
license = licenses.unfree;
platforms = [
"x86_64-linux"
"aarch64-linux"
"loongarch64-linux"
];
sourceProvenance = with sourceTypes; [ binaryNativeCode ];
maintainers = with maintainers; [
pokon548
xddxdd
];
mainProgram = "wechat-uos";
};
};
};
in
buildFHSEnv {
inherit (wechat) pname version meta;
+13 -7
View File
@@ -1,11 +1,17 @@
# Generated by ./update.sh - do not update manually!
# Last updated: 2025-02-21
# Last updated: 2025-09-25
{
version = "4.0.1.12";
amd64_url = "https://pro-store-packages.uniontech.com/appstore/pool/appstore/c/com.tencent.wechat/com.tencent.wechat_4.0.1.12_amd64.deb";
arm64_url = "https://pro-store-packages.uniontech.com/appstore/pool/appstore/c/com.tencent.wechat/com.tencent.wechat_4.0.1.12_arm64.deb";
loongarch64_url = "https://pro-store-packages.uniontech.com/appstore/pool/appstore/c/com.tencent.wechat/com.tencent.wechat_4.0.1.12_loongarch64.deb";
amd64_hash = "sha256-u0NbuB06my+v8yUxQ9CKSHp4nxHAcMEhVzbAozM9nQU=";
arm64_hash = "sha256-GZnIMikYS+TGvTrEl+PT7KyjmXOXXOc0PMxp3Xfpqo8=";
loongarch64_hash = "sha256-dON2EW1+2aiiCTuBdc+IwRAmC/x2bEcQcZcar7WOfZo=";
amd64 = {
url = "https://pro-store-packages.uniontech.com/appstore/pool/appstore/c/com.tencent.wechat/com.tencent.wechat_4.0.1.12_amd64.deb";
hash = "sha256-u0NbuB06my+v8yUxQ9CKSHp4nxHAcMEhVzbAozM9nQU=";
};
arm64 = {
url = "https://pro-store-packages.uniontech.com/appstore/pool/appstore/c/com.tencent.wechat/com.tencent.wechat_4.0.1.12_arm64.deb";
hash = "sha256-GZnIMikYS+TGvTrEl+PT7KyjmXOXXOc0PMxp3Xfpqo8=";
};
loongarch64 = {
url = "https://pro-store-packages.uniontech.com/appstore/pool/appstore/c/com.tencent.wechat/com.tencent.wechat_4.0.1.12_loongarch64.deb";
hash = "sha256-dON2EW1+2aiiCTuBdc+IwRAmC/x2bEcQcZcar7WOfZo=";
};
}
+15 -9
View File
@@ -1,7 +1,7 @@
#! /usr/bin/env nix-shell
#! nix-shell -i bash --pure --keep GITHUB_TOKEN -p nix git curl cacert nix-prefetch-git gzip
base_url_suffix="https://pro-store-packages.uniontech.com/appstore/dists/eagle/appstore/binary-"
base_url_suffix="https://pro-store-packages.uniontech.com/appstore/dists/eagle-pro/appstore/binary-"
base_url_appendix="/Packages.gz"
target_package="com.tencent.wechat"
packages_file="Packages.gz"
@@ -13,7 +13,7 @@ hash=()
for i in amd64 arm64 loongarch64
do
current_url=$base_url_suffix$i$base_url_appendix
curl -A "Mozilla/5.0 (X11; Linux x86_64; rv:125.0) Gecko/20100101 Firefox/125.0" -v -L -O $current_url
curl -A "debian APT-HTTP/1.3 (1.6.11)" -v -L -O $current_url
current_version=$(zgrep -A 20 "Package: $target_package" "$packages_file" | awk -v pkg="$target_package" '
BEGIN { found = 0 }
{
@@ -39,8 +39,8 @@ do
}
}
')
hash+=("$(nix --extra-experimental-features nix-command hash convert --hash-algo sha256 --to sri $sha256sum)")
url+=("https://pro-store-packages.uniontech.com/appstore/pool/appstore/c/com.tencent.wechat/com.tencent.wechat_"$version"_"$i".deb")
hash+=("$(nix --extra-experimental-features nix-command hash to-sri --type sha256 $sha256sum)")
done
cat >sources.nix <<EOF
@@ -48,12 +48,18 @@ cat >sources.nix <<EOF
# Last updated: $(date +%F)
{
version = "${version[0]}";
amd64_url = "${url[0]}";
arm64_url = "${url[1]}";
loongarch64_url = "${url[2]}";
amd64_hash = "${hash[0]}";
arm64_hash = "${hash[1]}";
loongarch64_hash = "${hash[2]}";
amd64 = {
url = "${url[0]}";
hash = "${hash[0]}";
};
arm64 = {
url = "${url[1]}";
hash = "${hash[1]}";
};
loongarch64 = {
url = "${url[2]}";
hash = "${hash[2]}";
};
}
EOF