about summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
authorPeder Bergebakken Sundt <pbsds@hotmail.com>2024-02-26 22:42:29 +0100
committerGitHub <noreply@github.com>2024-02-26 22:42:29 +0100
commit34f9da5f8c8c96c4acc36aa2339086ce0c59c9bf (patch)
tree7a2c2ae350063d69b8962eae3483e288ae3cf463 /pkgs
parent31c53f104be7c9b598149f3eaaadeee36caf9e6f (diff)
parent6d5db91a7f633661e454c50ec40cfb76acf90b10 (diff)
Merge pull request #291081 from pokon548/fix-wps-link
wpsoffice{-cn}: 11.1.0.11711 -> 11.1.0.11719
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/applications/office/wpsoffice/default.nix49
1 files changed, 39 insertions, 10 deletions
diff --git a/pkgs/applications/office/wpsoffice/default.nix b/pkgs/applications/office/wpsoffice/default.nix
index d336b9cd5ba54..78b559b8ff3fe 100644
--- a/pkgs/applications/office/wpsoffice/default.nix
+++ b/pkgs/applications/office/wpsoffice/default.nix
@@ -16,20 +16,49 @@
 , xorg
 , cups
 , pango
+, runCommandLocal
+, curl
+, coreutils
+, cacert
 , useChineseVersion ? false
 }:
-
+let
+  pkgVersion = "11.1.0.11719";
+  url =
+    if useChineseVersion then
+      "https://wps-linux-personal.wpscdn.cn/wps/download/ep/Linux2019/${lib.last (lib.splitVersion pkgVersion)}/wps-office_${pkgVersion}_amd64.deb"
+    else
+      "https://wdl1.pcfg.cache.wpscdn.com/wpsdl/wpsoffice/download/linux/${lib.last (lib.splitVersion pkgVersion)}/wps-office_${pkgVersion}.XA_amd64.deb";
+  hash =
+    if useChineseVersion then
+      "sha256-LgE5du2ZnMsAqgoQkY63HWyWYA5TLS5I8ArRYrpxffs="
+    else
+      "sha256-6fXzHSMzZDGuBubOXsHA0YEUGKcy5QIPg3noyxUbdjA=";
+  uri = builtins.replaceStrings [ "https://wps-linux-personal.wpscdn.cn" ] [ "" ] url;
+  securityKey = "7f8faaaa468174dc1c9cd62e5f218a5b";
+in
 stdenv.mkDerivation rec {
   pname = "wpsoffice";
-  version = "11.1.0.11711";
+  version = pkgVersion;
 
-  src = if useChineseVersion then fetchurl {
-    url = "https://wps-linux-personal.wpscdn.cn/wps/download/ep/Linux2019/${lib.last (lib.splitVersion version)}/wps-office_${version}_amd64.deb";
-    hash = "sha256-JHSTZZnOZoTpj8zF4C5PmjTkftEdxbeaqweY3ITiJto=";
-  } else fetchurl {
-    url = "https://wdl1.pcfg.cache.wpscdn.com/wpsdl/wpsoffice/download/linux/${lib.last (lib.splitVersion version)}/wps-office_${version}.XA_amd64.deb";
-    hash = "sha256-2apkSE/8Wm6/OQ4x5n1PE1emhovqOgD0NVTY5QZZTYA=";
-  };
+  src = 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 ];
+
+      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
+  '';
 
   unpackCmd = "dpkg -x $src .";
   sourceRoot = ".";
@@ -102,6 +131,6 @@ stdenv.mkDerivation rec {
     sourceProvenance = with sourceTypes; [ binaryNativeCode ];
     hydraPlatforms = [ ];
     license = licenses.unfreeRedistributable;
-    maintainers = with maintainers; [ mlatus th0rgal rewine ];
+    maintainers = with maintainers; [ mlatus th0rgal rewine pokon548 ];
   };
 }