biglybt: 3.5.0.0 -> 3.6.0.0
[NixPkgs.git] / pkgs / servers / onlyoffice-documentserver / default.nix
blob61ea3cf6fd9449e3718f7b3f67b3f39dafb169c4
1 { lib
2 , stdenv
3 , buildFHSEnv
4 , corefonts
5 , dejavu_fonts
6 , dpkg
7 , fetchurl
8 , gcc-unwrapped
9 , liberation_ttf_v1
10 , writeScript
11 , xorg
14 let
15   # var/www/onlyoffice/documentserver/server/DocService/docservice
16   onlyoffice-documentserver = stdenv.mkDerivation rec {
17     pname = "onlyoffice-documentserver";
18     version = "7.5.1";
20     src = fetchurl {
21       url = "https://github.com/ONLYOFFICE/DocumentServer/releases/download/v${lib.concatStringsSep "." (lib.take 3 (lib.splitVersion version))}/onlyoffice-documentserver_amd64.deb";
22       sha256 = "sha256-191PYpxs/TbVXoBPHvuyTp81ZMtw1YaFznY1hUSbh+0=";
23     };
25     preferLocalBuild = true;
27     unpackCmd = "dpkg -x $curSrc source";
29     nativeBuildInputs = [
30       dpkg
31     ];
33     installPhase = ''
34       # replace dangling symlinks which are not copied into fhs with actually files
35       rm lib/*.so*
36       for file in var/www/onlyoffice/documentserver/server/FileConverter/bin/*.so* ; do
37         ln -rs "$file" lib/$(basename "$file")
38       done
40       # NixOS uses systemd, not supervisor
41       rm -rf etc/supervisor
43       install -Dm755 usr/bin/documentserver-prepare4shutdown.sh -t $out/bin
44       # maintainer scripts which expect supervisorctl, try to write into the nix store or are handled by nixos modules
45       rm -rf usr/bin
47       # .deb default documentation
48       rm -rf usr/share
50       # required for bwrap --bind
51       mkdir -p var/lib/onlyoffice/ var/www/onlyoffice/documentserver/fonts/
53       mv * $out/
54     '';
56     # stripping self extracting javascript binaries likely breaks them
57     dontStrip = true;
59     passthru = {
60       fhs = buildFHSEnv {
61         name = "onlyoffice-wrapper";
63         targetPkgs = pkgs: [
64           gcc-unwrapped.lib
65           onlyoffice-documentserver
67           # fonts
68           corefonts
69           dejavu_fonts
70           liberation_ttf_v1
71         ];
73         extraBwrapArgs = [
74           "--bind var/lib/onlyoffice/ var/lib/onlyoffice/"
75           "--bind var/lib/onlyoffice/documentserver/sdkjs/common/ var/www/onlyoffice/documentserver/sdkjs/common/"
76           "--bind var/lib/onlyoffice/documentserver/sdkjs/slide/themes/ var/www/onlyoffice/documentserver/sdkjs/slide/themes/"
77           "--bind var/lib/onlyoffice/documentserver/fonts/ var/www/onlyoffice/documentserver/fonts/"
78           "--bind var/lib/onlyoffice/documentserver/server/FileConverter/bin/ var/www/onlyoffice/documentserver/server/FileConverter/bin/"
79         ];
81         runScript = writeScript "onlyoffice-documentserver-run-script" ''
82           export NODE_CONFIG_DIR=$2
83           export NODE_DISABLE_COLORS=1
84           export NODE_ENV=production-linux
86           if [[ $1 == DocService/docservice ]]; then
87             mkdir -p var/www/onlyoffice/documentserver/sdkjs/slide/themes/
88             # symlinking themes/src breaks discovery in allfontsgen
89             rm -rf var/www/onlyoffice/documentserver/sdkjs/slide/themes/src
90             cp -r ${onlyoffice-documentserver}/var/www/onlyoffice/documentserver/sdkjs/slide/themes/src var/www/onlyoffice/documentserver/sdkjs/slide/themes/
91             chmod -R u+w var/www/onlyoffice/documentserver/sdkjs/slide/themes/
93             # onlyoffice places generated files in those directores
94             rm -rf var/www/onlyoffice/documentserver/sdkjs/common/*
95             ${xorg.lndir}/bin/lndir -silent ${onlyoffice-documentserver}/var/www/onlyoffice/documentserver/sdkjs/common/ var/www/onlyoffice/documentserver/sdkjs/common/
96             rm -rf var/www/onlyoffice/documentserver/server/FileConverter/bin/*
97             ${xorg.lndir}/bin/lndir -silent ${onlyoffice-documentserver}/var/www/onlyoffice/documentserver/server/FileConverter/bin/ var/www/onlyoffice/documentserver/server/FileConverter/bin/
99             # https://github.com/ONLYOFFICE/document-server-package/blob/master/common/documentserver/bin/documentserver-generate-allfonts.sh.m4
100             echo -n Generating AllFonts.js, please wait...
101             "var/www/onlyoffice/documentserver/server/tools/allfontsgen"\
102               --input="${onlyoffice-documentserver}/var/www/onlyoffice/documentserver/core-fonts"\
103               --allfonts-web="var/www/onlyoffice/documentserver/sdkjs/common/AllFonts.js"\
104               --allfonts="var/www/onlyoffice/documentserver/server/FileConverter/bin/AllFonts.js"\
105               --images="var/www/onlyoffice/documentserver/sdkjs/common/Images"\
106               --selection="var/www/onlyoffice/documentserver/server/FileConverter/bin/font_selection.bin"\
107               --output-web="var/www/onlyoffice/documentserver/fonts"\
108               --use-system="true"
109             echo Done
111             echo -n Generating presentation themes, please wait...
112             "var/www/onlyoffice/documentserver/server/tools/allthemesgen"\
113               --converter-dir="var/www/onlyoffice/documentserver/server/FileConverter/bin"\
114               --src="var/www/onlyoffice/documentserver/sdkjs/slide/themes"\
115               --output="var/www/onlyoffice/documentserver/sdkjs/common/Images"
117             "var/www/onlyoffice/documentserver/server/tools/allthemesgen"\
118               --converter-dir="var/www/onlyoffice/documentserver/server/FileConverter/bin"\
119               --src="var/www/onlyoffice/documentserver/sdkjs/slide/themes"\
120               --output="var/www/onlyoffice/documentserver/sdkjs/common/Images"\
121               --postfix="ios"\
122               --params="280,224"
124             "var/www/onlyoffice/documentserver/server/tools/allthemesgen"\
125               --converter-dir="var/www/onlyoffice/documentserver/server/FileConverter/bin"\
126               --src="var/www/onlyoffice/documentserver/sdkjs/slide/themes"\
127               --output="var/www/onlyoffice/documentserver/sdkjs/common/Images"\
128               --postfix="android"\
129               --params="280,224"
130             echo Done
131           fi
133           exec var/www/onlyoffice/documentserver/server/$1
134         '';
135       };
136     };
138     meta = with lib; {
139       description = "ONLYOFFICE Document Server is an online office suite comprising viewers and editors";
140       mainProgram = "documentserver-prepare4shutdown.sh";
141       longDescription = ''
142         ONLYOFFICE Document Server is an online office suite comprising viewers and editors for texts, spreadsheets and presentations,
143         fully compatible with Office Open XML formats: .docx, .xlsx, .pptx and enabling collaborative editing in real time.
144       '';
145       homepage = "ONLYOFFICE Document Server is an online office suite comprising viewers and editors";
146       license = licenses.agpl3Plus;
147       platforms = [ "x86_64-linux" ];
148       sourceProvenance = [ sourceTypes.binaryNativeCode ];
149       maintainers = with maintainers; [ SuperSandro2000 ];
150     };
151   };
153 onlyoffice-documentserver