Merge pull request #268619 from tweag/lib-descriptions
[NixPkgs.git] / pkgs / applications / office / onlyoffice-bin / 7_5.nix
blob33744bb3831ef073fae2d71f5a6506555c722fbe
1 { stdenv
2 , lib
3 , fetchurl
4 , buildFHSEnv
5   # Alphabetic ordering below
6 , alsa-lib
7 , at-spi2-atk
8 , atk
9 , autoPatchelfHook
10 , cairo
11 , curl
12 , dbus
13 , dconf
14 , dpkg
15 , fontconfig
16 , gcc-unwrapped
17 , gdk-pixbuf
18 , glib
19 , glibc
20 , gsettings-desktop-schemas
21 , gst_all_1
22 , gtk2
23 , gtk3
24 , libpulseaudio
25 , libudev0-shim
26 , libdrm
27 , makeWrapper
28 , mesa
29 , noto-fonts-cjk-sans
30 , nspr
31 , nss
32 , pulseaudio
33 , qt5
34 , wrapGAppsHook
35 , xkeyboard_config
36 , xorg
38 let
40   # Note on fonts:
41   #
42   # OnlyOffice does not distribute unfree fonts, but makes it easy to pick up
43   # any fonts you install. See:
44   #
45   # * https://helpcenter.onlyoffice.com/en/installation/docs-community-install-fonts-linux.aspx
46   # * https://www.onlyoffice.com/blog/2020/04/how-to-add-new-fonts-to-onlyoffice-desktop-editors/
47   #
48   # As recommended there, you should download
49   #
50   #     arial.ttf, calibri.ttf, cour.ttf, symbol.ttf, times.ttf, wingding.ttf
51   #
52   # into `~/.local/share/fonts/`, otherwise the default template fonts, and
53   # things like bullet points, will not look as expected.
55   # TODO: Find out which of these fonts we'd be allowed to distribute along
56   #       with this package, or how to make this easier for users otherwise.
58   runtimeLibs = lib.makeLibraryPath [
59     curl
60     glibc
61     gcc-unwrapped.lib
62     libudev0-shim
63     pulseaudio
64   ];
66   derivation = stdenv.mkDerivation rec {
67     pname = "onlyoffice-desktopeditors";
68     version = "7.5.1";
69     minor = null;
70     src = fetchurl {
71       url = "https://github.com/ONLYOFFICE/DesktopEditors/releases/download/v${version}/onlyoffice-desktopeditors_amd64.deb";
72       sha256 = "sha256-Hf5CNbUUMuHZHDY3fgD4qpF4UASevscK8DTZlauyHhY=";
73     };
75     nativeBuildInputs = [
76       autoPatchelfHook
77       dpkg
78       makeWrapper
79       wrapGAppsHook
80     ];
82     buildInputs = [
83       alsa-lib
84       at-spi2-atk
85       atk
86       cairo
87       dbus
88       dconf
89       fontconfig
90       gdk-pixbuf
91       glib
92       gsettings-desktop-schemas
93       gst_all_1.gst-plugins-base
94       gst_all_1.gstreamer
95       gtk2
96       gtk3
97       libpulseaudio
98       libdrm
99       nspr
100       nss
101       mesa # libgbm
102       qt5.qtbase
103       qt5.qtdeclarative
104       qt5.qtsvg
105       qt5.qtwayland
106       xorg.libX11
107       xorg.libxcb
108       xorg.libXcomposite
109       xorg.libXcursor
110       xorg.libXdamage
111       xorg.libXext
112       xorg.libXfixes
113       xorg.libXi
114       xorg.libXrandr
115       xorg.libXrender
116       xorg.libXScrnSaver
117       xorg.libXtst
118     ];
120     dontWrapQtApps = true;
122     unpackPhase = ''
123       dpkg-deb --fsys-tarfile $src | tar -x --no-same-permissions --no-same-owner
124     '';
126     installPhase = ''
127       runHook preInstall
129       mkdir -p $out/{bin,lib,share}
131       mv usr/bin/* $out/bin
132       mv usr/share/* $out/share/
133       mv opt/onlyoffice/desktopeditors $out/share
135       for f in $out/share/desktopeditors/asc-de-*.png; do
136         size=$(basename "$f" ".png" | cut -d"-" -f3)
137         res="''${size}x''${size}"
138         mkdir -pv "$out/share/icons/hicolor/$res/apps"
139         ln -s "$f" "$out/share/icons/hicolor/$res/apps/onlyoffice-desktopeditors.png"
140       done;
142       substituteInPlace $out/bin/onlyoffice-desktopeditors \
143         --replace "/opt/onlyoffice/" "$out/share/"
145       ln -s $out/share/desktopeditors/DesktopEditors $out/bin/DesktopEditors
147       runHook postInstall
148     '';
150     preFixup = ''
151       gappsWrapperArgs+=(
152         --prefix LD_LIBRARY_PATH : "${runtimeLibs}" \
153         --set QT_XKB_CONFIG_ROOT "${xkeyboard_config}/share/X11/xkb" \
154         --set QTCOMPOSE "${xorg.libX11.out}/share/X11/locale" \
155         --set QT_QPA_PLATFORM "xcb"
156         # the bundled version of qt does not support wayland
157       )
158     '';
160     passthru.updateScript = ./update.sh;
161   };
165 # In order to download plugins, OnlyOffice uses /usr/bin/curl so we have to wrap it.
166 # Curl still needs to be in runtimeLibs because the library is used directly in other parts of the code.
167 # Fonts are also discovered by looking in /usr/share/fonts, so adding fonts to targetPkgs will include them
168 buildFHSEnv {
169   name = derivation.name;
171   targetPkgs = pkgs': [
172     curl
173     derivation
174     noto-fonts-cjk-sans
175   ];
177   runScript = "/bin/onlyoffice-desktopeditors";
179   extraInstallCommands = ''
180     mv $out/bin/$name $out/bin/onlyoffice-desktopeditors
181     mkdir -p $out/share
182     ln -s ${derivation}/share/icons $out/share
183     cp -r ${derivation}/share/applications $out/share
184     substituteInPlace $out/share/applications/onlyoffice-desktopeditors.desktop \
185         --replace "/usr/bin/onlyoffice-desktopeditors" "$out/bin/onlyoffice-desktopeditors"
186   '';
188   meta = with lib; {
189     description = "Office suite that combines text, spreadsheet and presentation editors allowing to create, view and edit local documents";
190     longDescription = ''
191       This version is broken on wlroots environments (e.g. Hyprland, Sway).
192       If you are using one of these environments, please use `onlyoffice-bin` instead.
193     '';
194     homepage = "https://www.onlyoffice.com/";
195     downloadPage = "https://github.com/ONLYOFFICE/DesktopEditors/releases";
196     changelog = "https://github.com/ONLYOFFICE/DesktopEditors/blob/master/CHANGELOG.md";
197     platforms = [ "x86_64-linux" ];
198     sourceProvenance = with sourceTypes; [ binaryNativeCode ];
199     license = licenses.agpl3Plus;
200     maintainers = with maintainers; [ nh2 gtrunsec ];
201   };