ripasso-cursive: cosmetic changes (#361736)
[NixPkgs.git] / pkgs / by-name / on / onlyoffice-documentserver / package.nix
blobe494344d72cd529a3829ff68f7a7d56ddeb3d2fe
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 = "8.1.3";
20     src = fetchurl ({
21       "aarch64-linux" = {
22         url = "https://github.com/ONLYOFFICE/DocumentServer/releases/download/v${version}/onlyoffice-documentserver_arm64.deb";
23         sha256 = "sha256-+7hHz1UcnlJNhBAVaYQwK0m2tkgsfbjqY3oa8XU0yxo=";
24       };
25       "x86_64-linux" = {
26         url = "https://github.com/ONLYOFFICE/DocumentServer/releases/download/v${version}/onlyoffice-documentserver_amd64.deb";
27         sha256 = "sha256-jCwcXb97Z9/ZofKLYneJxKAnaZE/Hwvm34GLQu/BoUM=";
28       };
29     }.${stdenv.hostPlatform.system} or (throw "unsupported system ${stdenv.hostPlatform.system}"));
31     preferLocalBuild = true;
33     unpackCmd = "dpkg -x $curSrc source";
35     nativeBuildInputs = [
36       dpkg
37     ];
39     installPhase = ''
40       # replace dangling symlinks which are not copied into fhs with actually files
41       rm lib/*.so*
42       for file in var/www/onlyoffice/documentserver/server/FileConverter/bin/*.so* ; do
43         ln -rs "$file" lib/$(basename "$file")
44       done
46       # NixOS uses systemd, not supervisor
47       rm -rf etc/supervisor
49       install -Dm755 usr/bin/documentserver-prepare4shutdown.sh -t $out/bin
50       # maintainer scripts which expect supervisorctl, try to write into the nix store or are handled by nixos modules
51       rm -rf usr/bin
53       # .deb default documentation
54       rm -rf usr/share
56       # required for bwrap --bind
57       mkdir -p var/lib/onlyoffice/ var/www/onlyoffice/documentserver/fonts/
59       mv * $out/
60     '';
62     # stripping self extracting javascript binaries likely breaks them
63     dontStrip = true;
65     passthru = {
66       fhs = buildFHSEnv {
67         name = "onlyoffice-wrapper";
69         targetPkgs = pkgs: [
70           gcc-unwrapped.lib
71           onlyoffice-documentserver
73           # fonts
74           corefonts
75           dejavu_fonts
76           liberation_ttf_v1
77         ];
79         extraBwrapArgs = [
80           "--bind var/lib/onlyoffice/ var/lib/onlyoffice/"
81           "--bind var/lib/onlyoffice/documentserver/sdkjs/common/ var/www/onlyoffice/documentserver/sdkjs/common/"
82           "--bind var/lib/onlyoffice/documentserver/sdkjs/slide/themes/ var/www/onlyoffice/documentserver/sdkjs/slide/themes/"
83           "--bind var/lib/onlyoffice/documentserver/fonts/ var/www/onlyoffice/documentserver/fonts/"
84           "--bind var/lib/onlyoffice/documentserver/server/FileConverter/bin/ var/www/onlyoffice/documentserver/server/FileConverter/bin/"
85         ];
87         runScript = writeScript "onlyoffice-documentserver-run-script" ''
88           export NODE_CONFIG_DIR=$2
89           export NODE_DISABLE_COLORS=1
90           export NODE_ENV=production-linux
92           if [[ $1 == DocService/docservice ]]; then
93             mkdir -p var/www/onlyoffice/documentserver/sdkjs/slide/themes/
94             # symlinking themes/src breaks discovery in allfontsgen
95             rm -rf var/www/onlyoffice/documentserver/sdkjs/slide/themes/src
96             cp -r ${onlyoffice-documentserver}/var/www/onlyoffice/documentserver/sdkjs/slide/themes/src var/www/onlyoffice/documentserver/sdkjs/slide/themes/
97             chmod -R u+w var/www/onlyoffice/documentserver/sdkjs/slide/themes/
99             # onlyoffice places generated files in those directores
100             rm -rf var/www/onlyoffice/documentserver/sdkjs/common/*
101             ${xorg.lndir}/bin/lndir -silent ${onlyoffice-documentserver}/var/www/onlyoffice/documentserver/sdkjs/common/ var/www/onlyoffice/documentserver/sdkjs/common/
102             rm -rf var/www/onlyoffice/documentserver/server/FileConverter/bin/*
103             ${xorg.lndir}/bin/lndir -silent ${onlyoffice-documentserver}/var/www/onlyoffice/documentserver/server/FileConverter/bin/ var/www/onlyoffice/documentserver/server/FileConverter/bin/
105             # https://github.com/ONLYOFFICE/document-server-package/blob/master/common/documentserver/bin/documentserver-generate-allfonts.sh.m4
106             echo -n Generating AllFonts.js, please wait...
107             "var/www/onlyoffice/documentserver/server/tools/allfontsgen"\
108               --input="${onlyoffice-documentserver}/var/www/onlyoffice/documentserver/core-fonts"\
109               --allfonts-web="var/www/onlyoffice/documentserver/sdkjs/common/AllFonts.js"\
110               --allfonts="var/www/onlyoffice/documentserver/server/FileConverter/bin/AllFonts.js"\
111               --images="var/www/onlyoffice/documentserver/sdkjs/common/Images"\
112               --selection="var/www/onlyoffice/documentserver/server/FileConverter/bin/font_selection.bin"\
113               --output-web="var/www/onlyoffice/documentserver/fonts"\
114               --use-system="true"
115             echo Done
117             echo -n Generating presentation themes, please wait...
118             "var/www/onlyoffice/documentserver/server/tools/allthemesgen"\
119               --converter-dir="var/www/onlyoffice/documentserver/server/FileConverter/bin"\
120               --src="var/www/onlyoffice/documentserver/sdkjs/slide/themes"\
121               --output="var/www/onlyoffice/documentserver/sdkjs/common/Images"
123             "var/www/onlyoffice/documentserver/server/tools/allthemesgen"\
124               --converter-dir="var/www/onlyoffice/documentserver/server/FileConverter/bin"\
125               --src="var/www/onlyoffice/documentserver/sdkjs/slide/themes"\
126               --output="var/www/onlyoffice/documentserver/sdkjs/common/Images"\
127               --postfix="ios"\
128               --params="280,224"
130             "var/www/onlyoffice/documentserver/server/tools/allthemesgen"\
131               --converter-dir="var/www/onlyoffice/documentserver/server/FileConverter/bin"\
132               --src="var/www/onlyoffice/documentserver/sdkjs/slide/themes"\
133               --output="var/www/onlyoffice/documentserver/sdkjs/common/Images"\
134               --postfix="android"\
135               --params="280,224"
136             echo Done
137           fi
139           exec var/www/onlyoffice/documentserver/server/$1
140         '';
141       };
142     };
144     meta = with lib; {
145       description = "ONLYOFFICE Document Server is an online office suite comprising viewers and editors";
146       mainProgram = "documentserver-prepare4shutdown.sh";
147       longDescription = ''
148         ONLYOFFICE Document Server is an online office suite comprising viewers and editors for texts, spreadsheets and presentations,
149         fully compatible with Office Open XML formats: .docx, .xlsx, .pptx and enabling collaborative editing in real time.
150       '';
151       homepage = "https://github.com/ONLYOFFICE/DocumentServer";
152       license = licenses.agpl3Plus;
153       platforms = [ "x86_64-linux" "aarch64-linux" ];
154       sourceProvenance = [ sourceTypes.binaryNativeCode ];
155       maintainers = with maintainers; [ SuperSandro2000 ];
156     };
157   };
159 onlyoffice-documentserver