Skip to content

Commit

Permalink
wpsoffice-365: init at 12.8.2.18605
Browse files Browse the repository at this point in the history
  • Loading branch information
pokon548 committed Nov 6, 2024
1 parent 0372d25 commit 39054d1
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 21 deletions.
91 changes: 70 additions & 21 deletions pkgs/applications/office/wpsoffice/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{ lib,
{
lib,
stdenv,
dpkg,
autoPatchelfHook,
Expand Down Expand Up @@ -31,9 +32,12 @@
runCommandLocal,
cacert,
coreutils,
useChineseVersion ? false
fetchurl,
useChineseVersion ? false,
use365Version ? false,
}:
let
sources = import ./sources.nix;
pkgVersion = "12.1.0.17900";
url =
if useChineseVersion then
Expand All @@ -50,27 +54,55 @@ let
in
stdenv.mkDerivation rec {
pname = "wpsoffice";
version = pkgVersion;
version = if use365Version then sources.version else pkgVersion;

src = runCommandLocal (if useChineseVersion then "wps-office_${version}_amd64.deb" else "wps-office_${version}.XA_amd64.deb")
{
outputHashMode = "recursive";
outputHashAlgo = "sha256";
outputHash = hash;
src =
if use365Version then
(
{
x86_64-linux = fetchurl {
url = sources.pro_amd64_url;
hash = sources.pro_amd64_hash;
};
aarch64-linux = fetchurl {
url = sources.pro_arm64_url;
hash = sources.pro_arm64_hash;
};
}
.${stdenv.system} or (throw "wpsoffice-365-${version}: ${stdenv.system} is unsupported.")
)
else if (stdenv.system == "x86_64-linux") then
runCommandLocal
(
if useChineseVersion then
"wps-office_${version}_amd64.deb"
else
"wps-office_${version}.XA_amd64.deb"
)
{
outputHashMode = "recursive";
outputHashAlgo = "sha256";
outputHash = hash;

nativeBuildInputs = [ curl coreutils ];
nativeBuildInputs = [
curl
coreutils
];

impureEnvVars = lib.fetchers.proxyImpureEnvVars;
SSL_CERT_FILE = "${cacert}/etc/ssl/certs/ca-bundle.crt";
} ''
timestamp10=$(date '+%s')
md5hash=($(echo -n "${securityKey}${uri}$timestamp10" | md5sum))
impureEnvVars = lib.fetchers.proxyImpureEnvVars;
SSL_CERT_FILE = "${cacert}/etc/ssl/certs/ca-bundle.crt";
}
''
timestamp10=$(date '+%s')
md5hash=($(echo -n "${securityKey}${uri}$timestamp10" | md5sum))
curl \
--retry 3 --retry-delay 3 \
"${url}?t=$timestamp10&k=$md5hash" \
> $out
'';
curl \
--retry 3 --retry-delay 3 \
"${url}?t=$timestamp10&k=$md5hash" \
> $out
''
else
(throw "${pname}-${version}: ${stdenv.system} is unsupported.");

unpackCmd = "dpkg -x $src .";
sourceRoot = ".";
Expand Down Expand Up @@ -165,15 +197,32 @@ stdenv.mkDerivation rec {
patchelf --add-needed libjpeg.so $out/opt/kingsoft/wps-office/office6/libwpsmain.so
# dlopen dependency
patchelf --add-needed libudev.so.1 $out/opt/kingsoft/wps-office/office6/addons/cef/libcef.so
# 365 specific: Font watermark
if [ -e $out/opt/kingsoft/wps-office/office6/libFontWatermark.so ]; then
patchelf --replace-needed libmysqlclient.so.18 libmysqlclient.so $out/opt/kingsoft/wps-office/office6/libFontWatermark.so
patchelf --add-rpath "${libmysqlclient}/lib/mariadb" $out/opt/kingsoft/wps-office/office6/libFontWatermark.so
fi
# 365 specific: xiezuo
if [ -e $out/opt/xiezuo/resources/qt-tools/platforminputcontexts/libfcitxplatforminputcontextplugin.so ]; then
patchelf --replace-needed libFcitxQt5DBusAddons.so.1 libFcitx5Qt5DBusAddons.so.1 $out/opt/xiezuo/resources/qt-tools/platforminputcontexts/libfcitxplatforminputcontextplugin.so
fi
'';

meta = with lib; {
description = "Office suite, formerly Kingsoft Office";
homepage = "https://www.wps.com";
platforms = [ "x86_64-linux" ];
platforms = [
"x86_64-linux"
"aarch64-linux"
];
sourceProvenance = with sourceTypes; [ binaryNativeCode ];
hydraPlatforms = [ ];
license = licenses.unfreeRedistributable;
maintainers = with maintainers; [ mlatus th0rgal rewine pokon548 ];
maintainers = with maintainers; [
mlatus
th0rgal
rewine
pokon548
];
};
}
9 changes: 9 additions & 0 deletions pkgs/applications/office/wpsoffice/sources.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Generated by ./update.sh - do not update manually!
# Last updated: 2024-11-06
{
version = "12.8.2.18605";
pro_arm64_url = "https://wps-linux-365.wpscdn.cn/wps/download/ep/Linux365/18605/wps-office_12.8.2.18605.AK.preload.sw_arm64.deb";
pro_amd64_url = "https://wps-linux-365.wpscdn.cn/wps/download/ep/Linux365/18605/wps-office_12.8.2.18605.AK.preload.sw_amd64.deb";
pro_arm64_hash = "sha256-BzWpCMzCzn4RFXve7oVd405ErrQLif5wwGdC938oUXw=";
pro_amd64_hash = "sha256-fy238yjdaV6pZOPulAMRJlcj/IHeRDjgMgrTVC0JPLQ=";
}
21 changes: 21 additions & 0 deletions pkgs/applications/office/wpsoffice/update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#! /usr/bin/env nix-shell
#! nix-shell -i bash --pure --keep GITHUB_TOKEN -p nix curl cacert nix-prefetch-git jq

download_json=$(curl 'https://plus.wps.cn/ops/opsd/api/v2/policy' --compressed -X POST -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:127.0) Gecko/20100101 Firefox/127.0' -H 'Accept: application/json' -H 'Accept-Language: en-US,en;q=0.5' -H 'Accept-Encoding: gzip, deflate, br, zstd' -H 'Content-Type: application/json;charset=utf-8' -H 'Origin: https://365.wps.cn' -H 'DNT: 1' -H 'Connection: keep-alive' -H 'Referer: https://365.wps.cn/' -H 'Sec-Fetch-Dest: empty' -H 'Sec-Fetch-Mode: cors' -H 'Sec-Fetch-Site: same-site' -H 'TE: trailers' --data-raw '{"entity_param":[{"window_key":"wps365_download_pc_muti"}]}')
arm64_url=$(echo $download_json | jq '.windows[0].data[3].value | fromjson | .[5].links[0].packageList[0].link' | sed 's/"//g')
amd64_url=$(echo $download_json | jq '.windows[0].data[3].value | fromjson | .[5].links[1].packageList[0].link' | sed 's/"//g')
version=$(echo $amd64_url | awk -F'[_]' '{print $2}' | awk -F'[AK]' '{print $1}' | sed -E 's/(.*)./\1/')
arm64_hash=$(nix hash to-sri --type sha256 "$(nix-prefetch-url $arm64_url)")
amd64_hash=$(nix hash to-sri --type sha256 "$(nix-prefetch-url $amd64_url)")

cat > sources.nix <<EOF
# Generated by ./update.sh - do not update manually!
# Last updated: $(date +%F)
{
version = "$version";
pro_arm64_url = "$arm64_url";
pro_amd64_url = "$amd64_url";
pro_arm64_hash = "$arm64_hash";
pro_amd64_hash = "$amd64_hash";
}
EOF
3 changes: 3 additions & 0 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -33248,6 +33248,9 @@ with pkgs;
wpsoffice-cn = libsForQt5.callPackage ../applications/office/wpsoffice {
useChineseVersion = true;
};
wpsoffice-365 = libsForQt5.callPackage ../applications/office/wpsoffice {
use365Version = true;
};

wrapFirefox = callPackage ../applications/networking/browsers/firefox/wrapper.nix { };

Expand Down

0 comments on commit 39054d1

Please sign in to comment.