wpsoffice-cn: init darwin at 12.1.24031 (#465508)

This commit is contained in:
rewine
2025-12-02 12:15:30 +00:00
committed by GitHub
3 changed files with 190 additions and 122 deletions
+151 -109
View File
@@ -1,6 +1,8 @@
{
lib,
stdenv,
fetchurl,
undmg,
autoPatchelfHook,
runCommandLocal,
curl,
@@ -30,128 +32,55 @@
let
pname = "wpsoffice-cn";
sources = import ./sources.nix;
version = sources.version;
version = if stdenv.hostPlatform.isDarwin then sources.darwin-version else sources.linux-version;
fetch =
{
url,
hash,
}:
runCommandLocal "wpsoffice-cn-${version}.deb"
if stdenv.hostPlatform.isDarwin then
fetchurl
else
{
outputHashAlgo = "sha256";
outputHash = hash;
url,
hash,
}:
runCommandLocal "wpsoffice-cn-${version}.deb"
{
outputHashAlgo = "sha256";
outputHash = hash;
nativeBuildInputs = [
curl
coreutils
];
nativeBuildInputs = [
curl
coreutils
];
impureEnvVars = lib.fetchers.proxyImpureEnvVars;
SSL_CERT_FILE = "${cacert}/etc/ssl/certs/ca-bundle.crt";
}
''
readonly SECURITY_KEY="7f8faaaa468174dc1c9cd62e5f218a5b"
impureEnvVars = lib.fetchers.proxyImpureEnvVars;
SSL_CERT_FILE = "${cacert}/etc/ssl/certs/ca-bundle.crt";
}
''
readonly SECURITY_KEY="7f8faaaa468174dc1c9cd62e5f218a5b"
timestamp10=$(date '+%s')
md5hash=($(printf '%s' "$SECURITY_KEY${lib.removePrefix "https://wps-linux-personal.wpscdn.cn" url}$timestamp10" | md5sum))
timestamp10=$(date '+%s')
md5hash=($(printf '%s' "$SECURITY_KEY${lib.removePrefix "https://wps-linux-personal.wpscdn.cn" url}$timestamp10" | md5sum))
curl --retry 3 --retry-delay 3 "${url}?t=$timestamp10&k=$md5hash" > $out
'';
srcs = {
x86_64-linux = fetch sources.x86_64;
};
curl --retry 3 --retry-delay 3 "${url}?t=$timestamp10&k=$md5hash" > $out
'';
src =
srcs.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
in
fetch
sources.${stdenv.hostPlatform.system}
or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
stdenv.mkDerivation {
inherit pname src version;
nativeBuildInputs = [ autoPatchelfHook ];
buildInputs = [
alsa-lib
libjpeg
libtool
libxkbcommon
nss
nspr
udev
gtk3
libgbm
libusb1
unixODBC
libsForQt5.qtbase
xorg.libXdamage
xorg.libXtst
xorg.libXv
];
dontWrapQtApps = true;
stripAllList = [ "opt" ];
runtimeDependencies = map lib.getLib [
cups
dbus
pango
];
unpackPhase = ''
# Unpack the .deb file
ar x $src
tar -xf data.tar.xz
# Remove unneeded files
rm -rf usr/share/{fonts,locale}
rm -f usr/bin/misc
rm -rf opt/kingsoft/wps-office/{desktops,INSTALL}
rm -f opt/kingsoft/wps-office/office6/lib{peony-wpsprint-menu-plugin,bz2,jpeg,stdc++,gcc_s,odbc*,nss*,dbus-1}.so*
'';
installPhase = ''
runHook preInstall
mkdir -p $out
cp -r opt $out
cp -r usr/{bin,share} $out
for i in $out/bin/*; do
substituteInPlace $i \
--replace-fail /opt/kingsoft/wps-office $out/opt/kingsoft/wps-office
done
for i in $out/share/applications/*; do
substituteInPlace $i \
--replace-fail /usr/bin $out/bin
done
runHook postInstall
'';
preFixup = ''
# dlopen dependency
patchelf --add-needed libudev.so.1 $out/opt/kingsoft/wps-office/office6/addons/cef/libcef.so
# libmysqlclient dependency
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
# fix et/wpp/wpspdf failure to launch with no mode configured
for i in $out/bin/*; do
substituteInPlace $i \
--replace-fail '[ $haveConf -eq 1 ] &&' '[ ! $currentMode ] ||'
done
'';
passthru.updateScript = ./update.sh;
passthru = {
updateScript = ./update.sh;
};
meta = {
description = "Office suite, formerly Kingsoft Office";
homepage = "https://www.wps.cn";
platforms = [ "x86_64-linux" ];
platforms = [
"aarch64-darwin"
"x86_64-darwin"
"x86_64-linux"
];
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
hydraPlatforms = [ ];
license = lib.licenses.unfree;
@@ -162,6 +91,119 @@ stdenv.mkDerivation {
pokon548
chillcicada
];
}
// lib.optionalAttrs stdenv.hostPlatform.isLinux {
changelog = "https://linux.wps.cn/wpslinuxlog";
mainProgram = "wps";
};
}
in
if stdenv.hostPlatform.isDarwin then
stdenv.mkDerivation {
inherit
pname
version
src
passthru
meta
;
nativeBuildInputs = [ undmg ];
sourceRoot = ".";
installPhase = ''
runHook preInstall
mkdir -p $out/Applications
cp -a wpsoffice.app $out/Applications
runHook postInstall
'';
}
else
stdenv.mkDerivation {
inherit
pname
version
src
passthru
meta
;
nativeBuildInputs = [ autoPatchelfHook ];
buildInputs = [
alsa-lib
libjpeg
libtool
libxkbcommon
nss
nspr
udev
gtk3
libgbm
libusb1
unixODBC
libsForQt5.qtbase
xorg.libXdamage
xorg.libXtst
xorg.libXv
];
dontWrapQtApps = true;
stripAllList = [ "opt" ];
runtimeDependencies = map lib.getLib [
cups
dbus
pango
];
unpackPhase = ''
# Unpack the .deb file
ar x $src
tar -xf data.tar.xz
# Remove unneeded files
rm -rf usr/share/{fonts,locale}
rm -f usr/bin/misc
rm -rf opt/kingsoft/wps-office/{desktops,INSTALL}
rm -f opt/kingsoft/wps-office/office6/lib{peony-wpsprint-menu-plugin,bz2,jpeg,stdc++,gcc_s,odbc*,nss*,dbus-1}.so*
'';
installPhase = ''
runHook preInstall
mkdir -p $out
cp -r opt $out
cp -r usr/{bin,share} $out
for i in $out/bin/*; do
substituteInPlace $i \
--replace-fail /opt/kingsoft/wps-office $out/opt/kingsoft/wps-office
done
for i in $out/share/applications/*; do
substituteInPlace $i \
--replace-fail /usr/bin $out/bin
done
runHook postInstall
'';
preFixup = ''
# dlopen dependency
patchelf --add-needed libudev.so.1 $out/opt/kingsoft/wps-office/office6/addons/cef/libcef.so
# libmysqlclient dependency
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
# fix et/wpp/wpspdf failure to launch with no mode configured
for i in $out/bin/*; do
substituteInPlace $i \
--replace-fail '[ $haveConf -eq 1 ] &&' '[ ! $currentMode ] ||'
done
'';
}
+12 -3
View File
@@ -1,9 +1,18 @@
# Generated by ./update.sh - do not update manually!
# Last updated: 2025-11-18
# Last updated: 2025-11-27
{
version = "12.1.2.23578";
x86_64 = {
linux-version = "12.1.2.23578";
darwin-version = "12.1.24031";
x86_64-linux = {
url = "https://wps-linux-personal.wpscdn.cn/wps/download/ep/Linux2023/23578/wps-office_12.1.2.23578.AK.preread.sw_542488_amd64.deb";
hash = "sha256-IMklnH6rCPZFHElLFF6At5QdDg7Ut/lBZFw+oPwQYWc=";
};
x86_64-darwin = {
url = "https://package.mac.wpscdn.cn/mac_wps_pkg/12.1.24031/WPS_Office_12.1.24031(24031)_x64.dmg";
hash = "sha256-i4i+o1OmgZdbPTkeRkqlATKnyC3L+tt9cdRQuH4VAXE=";
};
aarch64-darwin = {
url = "https://package.mac.wpscdn.cn/mac_wps_pkg/12.1.24031/WPS_Office_12.1.24031(24031)_arm64.dmg";
hash = "sha256-olOgQ8jzO/IFXGJc9YANPC12LoZhzbtSzXjyZXO9x84=";
};
}
+27 -10
View File
@@ -8,27 +8,44 @@ export SSL_CERT_FILE=$NIX_SSL_CERT_FILE
readonly SECURITY_KEY="7f8faaaa468174dc1c9cd62e5f218a5b"
prefix="https://wps-linux-personal.wpscdn.cn"
payload=$(curl -s "https://www.wps.cn/product/wpslinux")
linux_payload=$(curl -s "https://linux.wps.cn")
darwin_payload=$(curl -s "https://mac.wps.cn")
version=$(echo "$payload" | grep -oP '(?<=banner_txt">)[^<]+')
linux_version=$(echo "$linux_payload" | grep -oP '(?<=banner_txt">)[^<]+')
darwin_version=$(echo "$darwin_payload" | grep -oP '(?<=\s)\d+(?:\.\d+)+(?=/)')
amd64_url=$(echo "$payload" | grep -oP "downLoad\('[^']*'" | head -1 | sed "s/downLoad('//;s/'$//")
linux_amd64_url=$(echo "$linux_payload" | grep -oP "downLoad\('[^']*'" | head -1 | sed "s/downLoad('//;s/'$//")
darwin_amd64_url="https://package.mac.wpscdn.cn/mac_wps_pkg/${darwin_version}/WPS_Office_${darwin_version}(${darwin_version##*.})_x64.dmg"
darwin_arm64_url="https://package.mac.wpscdn.cn/mac_wps_pkg/${darwin_version}/WPS_Office_${darwin_version}(${darwin_version##*.})_arm64.dmg"
timestamp10=$(date '+%s')
amd64_md5hash=($(printf '%s' "$SECURITY_KEY${amd64_url#$prefix}$timestamp10" | md5sum))
linux_amd64_md5hash=($(printf '%s' "$SECURITY_KEY${linux_amd64_url#$prefix}$timestamp10" | md5sum))
amd64_hash=$(nix-prefetch-url --name "wpsoffice-cn-$version.deb" "$amd64_url?t=$timestamp10&k=$amd64_md5hash")
linux_amd64_hash=$(nix-prefetch-url --name "wpsoffice-cn-$linux_version.deb" "$linux_amd64_url?t=$timestamp10&k=$linux_amd64_md5hash")
darwin_amd64_hash=$(nix-prefetch-url --name "wpsoffice-cn-$darwin_version.dmg" "$darwin_amd64_url")
darwin_arm64_hash=$(nix-prefetch-url --name "wpsoffice-cn-$darwin_version.dmg" "$darwin_arm64_url")
amd64_hash=$(nix --extra-experimental-features nix-command hash convert --to sri --hash-algo sha256 "$amd64_hash")
linux_amd64_hash=$(nix --extra-experimental-features nix-command hash convert --to sri --hash-algo sha256 "$linux_amd64_hash")
darwin_amd64_hash=$(nix --extra-experimental-features nix-command hash convert --to sri --hash-algo sha256 "$darwin_amd64_hash")
darwin_arm64_hash=$(nix --extra-experimental-features nix-command hash convert --to sri --hash-algo sha256 "$darwin_arm64_hash")
cat > sources.nix << EOF
# Generated by ./update.sh - do not update manually!
# Last updated: $(date +%F)
{
version = "$version";
x86_64 = {
url = "$amd64_url";
hash = "$amd64_hash";
linux-version = "$linux_version";
darwin-version = "$darwin_version";
x86_64-linux = {
url = "$linux_amd64_url";
hash = "$linux_amd64_hash";
};
x86_64-darwin = {
url = "$darwin_amd64_url";
hash = "$darwin_amd64_hash";
};
aarch64-darwin = {
url = "$darwin_arm64_url";
hash = "$darwin_arm64_hash";
};
}
EOF