nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 235 lines 8.4 kB view raw
1{ 2 buildFHSEnv, 3 buildNpmPackage, 4 dpkg, 5 fetchFromGitHub, 6 fetchurl, 7 gcc-unwrapped, 8 lib, 9 lndir, 10 nixosTests, 11 pkg-config, 12 runCommand, 13 stdenv, 14 vips, 15 writeScript, 16 x2t, 17 18 extra-fonts ? [ ], 19}: 20 21let 22 version = "9.2.1"; 23 server-src = fetchFromGitHub { 24 owner = "ONLYOFFICE"; 25 repo = "server"; 26 tag = "v9.2.1.1"; 27 hash = "sha256-McG+PGL+ZmmnInuBhqVqMeX0o36/LbC0C5vQA1TDjO8="; 28 }; 29 common = buildNpmPackage (finalAttrs: { 30 name = "onlyoffice-server-Common"; 31 src = server-src; 32 sourceRoot = "${finalAttrs.src.name}/Common"; 33 npmDepsHash = "sha256-zFGqDtnNFzXCwp6uvK04GDMRG6BATv6ti3Wi8ikLjBU="; 34 dontNpmBuild = true; 35 postPatch = '' 36 # https://github.com/ONLYOFFICE/build_tools/blob/ef8153c053bed41909ceb0762b124f8fe7faa0a7/scripts/build_server.py#L34 37 sed -e "s/^const buildVersion = '[0-9.]*'/const buildVersion = '${version}'/" -i sources/commondefines.js 38 ''; 39 postInstall = '' 40 ln -s $out/lib/node_modules/common $out/lib/node_modules/Common 41 ''; 42 }); 43 docservice = buildNpmPackage (finalAttrs: { 44 name = "onlyoffice-server-DocService"; 45 src = server-src; 46 sourceRoot = "${finalAttrs.src.name}/DocService"; 47 nativeBuildInputs = [ 48 pkg-config 49 ]; 50 buildInputs = [ 51 vips.dev 52 ]; 53 npmDepsHash = "sha256-4t3wrO+Tt3bTRzmvB+tbVr5D3fXpn7CCU7+dNRc7xEo="; 54 npmFlags = [ "--loglevel=verbose" ]; 55 dontNpmBuild = true; 56 postInstall = '' 57 # it would be neater if this were a 'ln -s', but this is not possible 58 # because common/sources/notificationService.js has a circular dependency 59 # back on DocService 60 cp -r ${common}/lib/node_modules/common $out/lib/node_modules/Common 61 ln -s $out/lib/node_modules/coauthoring $out/lib/node_modules/DocService 62 ''; 63 }); 64 fileconverter = buildNpmPackage (finalAttrs: { 65 name = "onlyoffice-server-FileConverter"; 66 src = server-src; 67 68 sourceRoot = "${finalAttrs.src.name}/FileConverter"; 69 70 npmDepsHash = "sha256-JKZqbpVBNe6dwxsTg8WqlJAlAqOYmqm+LyWgIxpRb8k="; 71 72 dontNpmBuild = true; 73 74 postInstall = '' 75 ln -s ${common}/lib/node_modules/common $out/lib/node_modules/Common 76 ln -s ${docservice}/lib/node_modules/coauthoring $out/lib/node_modules/DocService 77 ''; 78 }); 79 80 # https://github.com/ONLYOFFICE/document-server-package/blob/master/common/documentserver/bin/documentserver-generate-allfonts.sh.m4 81 x2t-with-fonts-and-themes = runCommand "x2t-with-fonts-and-themes" { } '' 82 mkdir -p $out/web 83 mkdir -p $out/converter 84 mkdir -p $out/images 85 mkdir -p $out/fonts 86 87 echo Generating fonts 88 export CUSTOM_FONTS_PATHS=${lib.concatStringsSep ":" extra-fonts} 89 ${x2t.components.allfontsgen}/bin/allfontsgen \ 90 --input=${x2t.components.core-fonts} \ 91 --allfonts-web=$out/web/AllFonts.js \ 92 --allfonts=$out/converter/AllFonts.js \ 93 --images=$out/images \ 94 --selection=$out/converter/font_selection.bin \ 95 --output-web=$out/fonts \ 96 --use-system=true 97 98 mkdir -p $out/bin 99 cp ${x2t}/bin/x2t $out/bin 100 cat >$out/bin/DoctRenderer.config <<EOF 101 <Settings> 102 <file>${x2t.components.sdkjs}/common/Native/native.js</file> 103 <file>${x2t.components.sdkjs}/common/Native/jquery_native.js</file> 104 <allfonts>$out/converter/AllFonts.js</allfonts> 105 <file>${x2t.components.web-apps}/vendor/xregexp/xregexp-all-min.js</file> 106 <sdkjs>${x2t.components.sdkjs}</sdkjs> 107 <dictionaries>${x2t.components.dictionaries}</dictionaries> 108 </Settings> 109 EOF 110 111 echo Generating presentation themes 112 # creates temporary files next to sources... 113 mkdir working 114 cp ${x2t.components.sdkjs}/slide/themes/src/* working 115 ${x2t.components.allthemesgen}/bin/allthemesgen \ 116 --converter-dir="$out/bin"\ 117 --src="working"\ 118 --output="$out/images" 119 ${x2t.components.allthemesgen}/bin/allthemesgen \ 120 --converter-dir="$out/bin"\ 121 --src="working"\ 122 --output="$out/images"\ 123 --postfix="ios"\ 124 --params="280,224" 125 ${x2t.components.allthemesgen}/bin/allthemesgen \ 126 --converter-dir="$out/bin"\ 127 --src="working"\ 128 --output="$out/images"\ 129 --postfix="android"\ 130 --params="280,224" 131 ''; 132 # var/www/onlyoffice/documentserver/server/DocService/docservice 133 onlyoffice-documentserver = stdenv.mkDerivation { 134 pname = "onlyoffice-documentserver"; 135 version = "9.2.1"; 136 137 src = fetchFromGitHub { 138 owner = "ONLYOFFICE"; 139 repo = "document-server-package"; 140 tag = "v9.2.1.13"; 141 hash = "sha256-jyXSYkWu63vdeWsRm1Pl/3p3jRjasj0whzN0CytdHks="; 142 }; 143 144 buildPhase = '' 145 runHook preBuild 146 # nothing for now 147 runHook postBuild 148 ''; 149 150 installPhase = '' 151 mkdir -p $out/etc/onlyoffice/documentserver/log4js 152 cp ${server-src}/Common/config/default.json $out/etc/onlyoffice/documentserver 153 cp ${server-src}/Common/config/production-linux.json $out/etc/onlyoffice/documentserver 154 cp ${server-src}/Common/config/log4js/production.json $out/etc/onlyoffice/documentserver/log4js 155 156 mkdir -p $out/var/www/onlyoffice/documentserver-example 157 cp -r common/documentserver-example/welcome $out/var/www/onlyoffice/documentserver-example 158 159 mkdir -p $out/var/www/onlyoffice/documentserver 160 161 # equivalent of usr/bin/documentserver-flush-cache.sh, 162 # busts cache also when fonts collection changes 163 mkdir $out/var/www/onlyoffice/documentserver/web-apps 164 ${lndir}/bin/lndir -silent ${x2t.components.web-apps} $out/var/www/onlyoffice/documentserver/web-apps 165 mv $out/var/www/onlyoffice/documentserver/web-apps/apps/api/documents/api.js{,.orig} 166 sed -e "s/{{HASH_POSTFIX}}/$(basename $out | cut -d '-' -f 1)/" $out/var/www/onlyoffice/documentserver/web-apps/apps/api/documents/api.js.orig > $out/var/www/onlyoffice/documentserver/web-apps/apps/api/documents/api.js 167 168 ln -s ${x2t-with-fonts-and-themes}/fonts $out/var/www/onlyoffice/documentserver/fonts 169 170 mkdir -p $out/var/www/onlyoffice/documentserver/sdkjs 171 ${lndir}/bin/lndir -silent ${x2t.components.sdkjs} $out/var/www/onlyoffice/documentserver/sdkjs 172 ln -s ${x2t-with-fonts-and-themes}/web/AllFonts.js $out/var/www/onlyoffice/documentserver/sdkjs/common/AllFonts.js 173 ${lndir}/bin/lndir -silent ${x2t-with-fonts-and-themes}/images $out/var/www/onlyoffice/documentserver/sdkjs/common/Images 174 175 # we don't currently support sdkjs plugins in NixOS 176 # https://github.com/ONLYOFFICE/build_tools/blob/master/scripts/deploy_server.py#L130 177 mkdir -p $out/var/www/onlyoffice/documentserver/sdkjs-plugins 178 echo "[]" > $out/var/www/onlyoffice/documentserver/sdkjs-plugins/plugin-list-default.json 179 180 mkdir -p $out/var/www/onlyoffice/documentserver/server/schema 181 cp -r ${server-src}/schema/* $out/var/www/onlyoffice/documentserver/server/schema 182 183 ## required for bwrap --bind 184 chmod u+w $out/var 185 mkdir -p $out/var/lib/onlyoffice 186 ''; 187 188 # stripping self extracting javascript binaries likely breaks them 189 dontStrip = true; 190 191 passthru = { 192 inherit 193 x2t-with-fonts-and-themes 194 common 195 docservice 196 fileconverter 197 ; 198 tests = nixosTests.onlyoffice; 199 fhs = buildFHSEnv { 200 name = "onlyoffice-wrapper"; 201 202 targetPkgs = pkgs: [ 203 gcc-unwrapped.lib 204 onlyoffice-documentserver 205 fileconverter 206 ]; 207 208 extraBuildCommands = '' 209 mkdir -p $out/var/{lib/onlyoffice,www} 210 cp -ar ${onlyoffice-documentserver}/var/www/* $out/var/www/ 211 ''; 212 213 extraBwrapArgs = [ 214 "--bind var/lib/onlyoffice/ var/lib/onlyoffice/" 215 ]; 216 }; 217 }; 218 219 meta = { 220 description = "ONLYOFFICE Document Server is an online office suite comprising viewers and editors"; 221 longDescription = '' 222 ONLYOFFICE Document Server is an online office suite comprising viewers and editors for texts, spreadsheets and presentations, 223 fully compatible with Office Open XML formats: .docx, .xlsx, .pptx and enabling collaborative editing in real time. 224 ''; 225 homepage = "https://github.com/ONLYOFFICE/DocumentServer"; 226 license = lib.licenses.agpl3Plus; 227 platforms = [ 228 "x86_64-linux" 229 "aarch64-linux" 230 ]; 231 maintainers = with lib.maintainers; [ raboof ]; 232 }; 233 }; 234in 235onlyoffice-documentserver