nixpkgs/pkgs/applications/office/wpsoffice/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

109 lines
3.0 KiB
Nix
Raw Normal View History

2022-08-26 13:14:46 +00:00
{ lib
, stdenv
, fetchurl
, dpkg
, wrapGAppsHook
, wrapQtAppsHook
2022-08-26 13:14:46 +00:00
, autoPatchelfHook
, alsa-lib
, libtool
, nspr
2022-08-26 13:14:46 +00:00
, mesa
, libtiff
, cups
, udev
, xorg
2021-06-09 03:42:03 +00:00
, makeWrapper
2022-08-26 13:14:46 +00:00
, useChineseVersion ? false
}:
2017-06-04 11:47:27 +00:00
stdenv.mkDerivation rec {
2019-08-13 21:52:01 +00:00
pname = "wpsoffice";
version = "11.1.0.11698";
2016-02-23 15:36:54 +00:00
2022-08-26 13:14:46 +00:00
src = if useChineseVersion then fetchurl {
url = "https://wps-linux-personal.wpscdn.cn/wps/download/ep/Linux2019/${lib.last (lib.splitString "." version)}/wps-office_${version}_amd64.deb";
sha256 = "sha256-m7BOE2IF2m75mV/4X3HY9UJcidL0S0biqkidddp4LbQ=";
2022-08-26 13:14:46 +00:00
} else fetchurl {
url = "https://wdl1.pcfg.cache.wpscdn.com/wpsdl/wpsoffice/download/linux/${lib.last (lib.splitString "." version)}/wps-office_${version}.XA_amd64.deb";
sha256 = "sha256-spqxQK/xTE8yFPmGbSbrDY1vSxkan2kwAWpCWIExhgs=";
2016-02-23 15:36:54 +00:00
};
2022-08-26 13:14:46 +00:00
unpackCmd = "dpkg -x $src .";
sourceRoot = ".";
2022-08-26 13:14:46 +00:00
postUnpack = ''
# distribution is missing libkappessframework.so, so we should not let
# autoPatchelfHook fail on the following dead libraries
2022-08-26 13:14:46 +00:00
rm -r opt/kingsoft/wps-office/office6/addons/pdfbatchcompression
2022-08-26 13:14:46 +00:00
# Remove the following libraries because they depend on qt4
rm -r opt/kingsoft/wps-office/office6/{librpcetapi.so,librpcwpsapi.so,librpcwppapi.so,libavdevice.so.58.10.100,libmediacoder.so}
rm -r opt/kingsoft/wps-office/office6/addons/wppcapturer/libwppcapturer.so
rm -r opt/kingsoft/wps-office/office6/addons/wppencoder/libwppencoder.so
'';
2022-08-26 13:14:46 +00:00
nativeBuildInputs = [ dpkg wrapGAppsHook wrapQtAppsHook makeWrapper autoPatchelfHook ];
2016-02-23 15:36:54 +00:00
2022-08-26 13:14:46 +00:00
buildInputs = [
alsa-lib
2022-08-26 13:14:46 +00:00
xorg.libXdamage
xorg.libXtst
libtool
nspr
2022-08-26 13:14:46 +00:00
mesa
libtiff
udev
2016-02-23 15:36:54 +00:00
];
runtimeDependencies = [
cups.lib
];
2023-05-03 03:40:15 +00:00
2022-08-26 13:14:46 +00:00
installPhase = ''
runHook preInstall
2017-06-04 11:47:27 +00:00
prefix=$out/opt/kingsoft/wps-office
mkdir -p $out
cp -r opt $out
cp -r usr/* $out
for i in wps wpp et wpspdf; do
substituteInPlace $out/bin/$i \
2017-06-04 11:47:27 +00:00
--replace /opt/kingsoft/wps-office $prefix
done
for i in $out/share/applications/*;do
substituteInPlace $i \
--replace /usr/bin $out/bin
done
2022-08-26 13:14:46 +00:00
runHook postInstall
2021-06-09 03:42:03 +00:00
'';
dontWrapQtApps = true;
dontWrapGApps = true;
2022-08-26 13:14:46 +00:00
preFixup = ''
# The following libraries need libtiff.so.5, but nixpkgs provides libtiff.so.6
patchelf --replace-needed libtiff.so.5 libtiff.so $out/opt/kingsoft/wps-office/office6/{libpdfmain.so,libqpdfpaint.so,qt/plugins/imageformats/libqtiff.so}
# dlopen dependency
patchelf --add-needed libudev.so.1 $out/opt/kingsoft/wps-office/office6/addons/cef/libcef.so
'';
postFixup = ''
for f in "$out"/bin/*; do
echo "Wrapping $f"
wrapProgram "$f" \
"''${gappsWrapperArgs[@]}" \
2021-06-09 03:42:03 +00:00
"''${qtWrapperArgs[@]}"
done
'';
2022-08-26 13:14:46 +00:00
meta = with lib; {
description = "Office suite, formerly Kingsoft Office";
homepage = "https://www.wps.com";
platforms = [ "x86_64-linux" ];
2023-04-03 08:52:32 +00:00
sourceProvenance = with sourceTypes; [ binaryNativeCode ];
2022-08-26 13:14:46 +00:00
hydraPlatforms = [ ];
license = licenses.unfreeRedistributable;
maintainers = with maintainers; [ mlatus th0rgal rewine ];
};
}