From b80b16d3bbb901c9073b0deb3a77af61c7475e9e Mon Sep 17 00:00:00 2001 From: Arnout Engelen Date: Fri, 23 Jan 2026 10:21:13 +0100 Subject: [PATCH] onlyoffice-documentserver: reintroduce mobile assets These got lost in #473316 --- pkgs/by-name/x2/x2t/package.nix | 120 ++++++++++++++++-- .../x2/x2t/web-apps-mobile-no-spinner.patch | 20 +++ pkgs/by-name/x2/x2t/web-apps-no-mobile.patch | 13 ++ 3 files changed, 143 insertions(+), 10 deletions(-) create mode 100644 pkgs/by-name/x2/x2t/web-apps-mobile-no-spinner.patch create mode 100644 pkgs/by-name/x2/x2t/web-apps-no-mobile.patch diff --git a/pkgs/by-name/x2/x2t/package.nix b/pkgs/by-name/x2/x2t/package.nix index 79c1f78f0e03..9d619cdfd18e 100644 --- a/pkgs/by-name/x2/x2t/package.nix +++ b/pkgs/by-name/x2/x2t/package.nix @@ -15,14 +15,15 @@ icu, jdk, lib, - # workaround https://github.com/NixOS/nixpkgs/issues/477805 nodejs_22, # needs to be static and built with MD2 support! openssl, pkg-config, + python3, qt5, runCommand, stdenv, + writers, writeScript, x2t, grunt-cli, @@ -30,7 +31,6 @@ let qmake = qt5.qmake; - libv8 = nodejs_22.libv8; fixIcu = writeScript "fix-icu.sh" '' substituteInPlace \ $BUILDRT/Common/3dParty/icu/icu.pri \ @@ -131,8 +131,90 @@ let rev = core-rev; hash = "sha256-RSoCRcUGnavcNdZEfmBdtxJbEXhiOvbA8IwSeGBkWcs="; }; + # mini implementation of https://github.com/kentcdodds/cross-env + # because that was not trivial to package and we don't need most + # of its functionality anyway + cross-env = writers.writePython3Bin "cross-env" { } '' + import os + import subprocess + import sys + + env = os.environ + cmd = [] + + for k in sys.argv[1:]: + if '=' in k: + env[k.split('=')[0]] = k.split('=')[1] + else: + cmd += [k] + + subprocess.run(cmd, env=env) + ''; + # rev that the 'web-apps' submodule in documentserver points at + web-apps-rev = "c2074bbff69902490d49fa7fb511801a11c581f4"; + web-apps-hash = "sha256-i+m8a1b8RaVmyUAC+FiEdSyXmPWse9XaJaaLL7iq73o="; + web-apps-mobile = buildNpmPackage (finalAttrs: { + name = "web-apps-mobile"; + + src = fetchFromGitHub { + owner = "ONLYOFFICE"; + repo = "web-apps"; + rev = web-apps-rev; + hash = web-apps-hash; + }; + + patches = [ + # the spinner floods the output to the point of + # exhausting memory... + ./web-apps-mobile-no-spinner.patch + ]; + + sourceRoot = "${finalAttrs.src.name}/vendor/framework7-react"; + + npmDepsHash = "sha256-EBUseLFZ5Hc1DHRWL/2erOjlxfm4wHgyIURi5XTXNP8="; + + dontNpmBuild = true; + + preBuild = '' + export PRODUCT_VERSION=${version} + # 'd' is for 'debug' + export BUILD_NUMBER=$(echo "${web-apps-rev}" | tr d _) + ''; + + installPhase = '' + runHook preInstall + + chmod u+wx ../../apps/*/mobile + + npm run deploy-word + mkdir -p $out/documenteditor/mobile + mv ../../apps/documenteditor/mobile/css $out/documenteditor/mobile + mv ../../apps/documenteditor/mobile/dist $out/documenteditor/mobile + mv ../../apps/documenteditor/mobile/index.html $out/documenteditor/mobile + + npm run deploy-cell + mkdir -p $out/spreadsheeteditor/mobile + mv ../../apps/spreadsheeteditor/mobile/css $out/spreadsheeteditor/mobile + mv ../../apps/spreadsheeteditor/mobile/dist $out/spreadsheeteditor/mobile + mv ../../apps/spreadsheeteditor/mobile/index.html $out/spreadsheeteditor/mobile + + npm run deploy-slide + mkdir -p $out/presentationeditor/mobile + mv ../../apps/presentationeditor/mobile/css $out/presentationeditor/mobile + mv ../../apps/presentationeditor/mobile/dist $out/presentationeditor/mobile + mv ../../apps/presentationeditor/mobile/index.html $out/presentationeditor/mobile + + npm run deploy-visio + mkdir -p $out/visioeditor/mobile + mv ../../apps/visioeditor/mobile/css $out/visioeditor/mobile + mv ../../apps/visioeditor/mobile/dist $out/visioeditor/mobile + mv ../../apps/visioeditor/mobile/index.html $out/visioeditor/mobile + + runHook postInstall + ''; + }); web-apps = buildNpmPackage (finalAttrs: { - name = "onlyoffice-core-webapps"; + name = "onlyoffice-core-web-apps"; # workaround for https://github.com/NixOS/nixpkgs/issues/477803 nodejs = nodejs_22; @@ -141,13 +223,16 @@ let owner = "ONLYOFFICE"; repo = "web-apps"; # rev that the 'web-apps' submodule in documentserver points at - rev = "c2074bbff69902490d49fa7fb511801a11c581f4"; - hash = "sha256-i+m8a1b8RaVmyUAC+FiEdSyXmPWse9XaJaaLL7iq73o="; + rev = web-apps-rev; + hash = web-apps-hash; }; sourceRoot = "${finalAttrs.src.name}/build"; patches = [ ./web-apps-avoid-phantomjs.patch + # mobile resources are created separately + # in the web-apps-mobile derivation + ./web-apps-no-mobile.patch ]; npmDepsHash = "sha256-Uen7gl6w/0A4MDk+7j+exkdwfCYqMSPJidad8AM60eQ="; @@ -163,6 +248,10 @@ let preBuild = '' export PRODUCT_VERSION=${version} + + # for device_scale.js + chmod u+rwx ../.. + ln -s ${sdkjs.src} ../../sdkjs ''; postBuild = '' @@ -173,13 +262,20 @@ let mkdir -p ./node_modules/optipng-bin/vendor ln -s ${optipng}/bin/optipng ./node_modules/optipng-bin/vendor/optipng - grunt --force + grunt ''; installPhase = '' runHook preInstall - cp -r ../deploy/web-apps $out + mv ../deploy/web-apps $out + + for component in documenteditor spreadsheeteditor presentationeditor visioeditor; do + ln -s ${web-apps-mobile}/$component/mobile/css $out/apps/$component/mobile/css + rm -r $out/apps/$component/mobile/dist + ln -s ${web-apps-mobile}/$component/mobile/dist $out/apps/$component/mobile/dist + ln -s ${web-apps-mobile}/$component/mobile/index.html $out/apps/$component/mobile/index.html + done runHook postInstall ''; @@ -220,7 +316,8 @@ let installPhase = '' runHook preInstall - cp -r ../deploy/sdkjs $out + mv ../deploy/sdkjs $out + cp ../common/device_scale.js $out/common runHook postInstall ''; @@ -633,8 +730,9 @@ let echo "== v8 ==" mkdir -p Common/3dParty/v8_89/v8/out.gn/linux_64 - ln -s ${libv8}/lib Common/3dParty/v8_89/v8/out.gn/linux_64/obj - tar xf ${libv8.src} --one-top-level=/tmp/xxxxx + # using nodejs_22 here is a workaround for https://github.com/NixOS/nixpkgs/issues/477805 + ln -s ${nodejs_22.libv8}/lib Common/3dParty/v8_89/v8/out.gn/linux_64/obj + tar xf ${nodejs_22.libv8.src} --one-top-level=/tmp/xxxxx for i in /tmp/xxxxx/*/deps/v8/*; do cp -r $i Common/3dParty/v8_89/v8/ done @@ -868,6 +966,8 @@ buildCoreComponent "X2tConverter/build/Qt" { fb2file iworkfile web-apps + web-apps-mobile + cross-env sdkjs dictionaries ; diff --git a/pkgs/by-name/x2/x2t/web-apps-mobile-no-spinner.patch b/pkgs/by-name/x2/x2t/web-apps-mobile-no-spinner.patch new file mode 100644 index 000000000000..b07f420dc4d6 --- /dev/null +++ b/pkgs/by-name/x2/x2t/web-apps-mobile-no-spinner.patch @@ -0,0 +1,20 @@ +diff --git a/vendor/framework7-react/build/build.js b/vendor/framework7-react/build/build.js +index 50828275f1..48a609e033 100644 +--- a/build/build.js ++++ b/build/build.js +@@ -12,14 +12,13 @@ Promise.all([ + const { default: ora } = oramodule, + { default: chalk } = chalkmodule; + +- const spinner = ora(env === 'production' ? 'building for production...' : 'building development version...').start(); ++ console.log(env === 'production' ? 'building for production...' : 'building development version...'); + + rm('./www/', (removeErr) => { + if (removeErr) throw removeErr; + + webpack(config, (err, stats) => { + if (err) throw err; +- spinner.stop(); + + process.stdout.write(`${stats.toString({ + colors: true, diff --git a/pkgs/by-name/x2/x2t/web-apps-no-mobile.patch b/pkgs/by-name/x2/x2t/web-apps-no-mobile.patch new file mode 100644 index 000000000000..288af88e42ad --- /dev/null +++ b/pkgs/by-name/x2/x2t/web-apps-no-mobile.patch @@ -0,0 +1,13 @@ +diff --git a/build/Gruntfile.js b/build/Gruntfile.js +index 044fa02213..d4fac2ff01 100644 +--- a/Gruntfile.js ++++ b/Gruntfile.js +@@ -830,7 +830,7 @@ module.exports = function(grunt) { + 'replace:writeVersion', 'replace:prepareHelp', 'clean:postbuild']); + + grunt.registerTask('deploy-app-mobile', ['mobile-app-init', 'clean:deploy', /*'cssmin',*/ /*'copy:template-backup',*/ +- 'htmlmin', /*'requirejs',*/ 'exec:webpack_install', 'exec:webpack_app_build', /*'copy:template-restore',*/ ++ 'htmlmin', /*'requirejs',*/ /*'exec:webpack_install', 'exec:webpack_app_build',*/ /*'copy:template-restore',*/ + /*'clean:template-backup',*/ 'copy:localization', 'copy:index-page', + 'copy:images-app', 'copy:webpack-dist', 'concat', 'json-minify'/*,*/ + /*'replace:writeVersion', 'replace:fixResourceUrl'*/]);