x2t: avoid dependency on upstream deb

Build sdkjs and web-apps from source

This can hopefully eventually be shared with documentserver,
but let's take it one step at a time

Make explicit that only linux is supported (previously that was implicit
because onlyoffice-documentserver only supported linux)
This commit is contained in:
Arnout Engelen 2025-06-07 16:44:49 +02:00
parent 273fc19ccb
commit 4136b386ed
No known key found for this signature in database
GPG Key ID: 061107B0F74A6DAA
2 changed files with 125 additions and 14 deletions

View File

@ -1,17 +1,23 @@
{
stdenv,
lib,
fetchFromGitHub,
pkg-config,
autoconf,
automake,
boost,
icu,
qt5,
buildNpmPackage,
closurecompiler,
fetchFromGitHub,
glibc,
harfbuzz,
icu,
jdk,
lib,
nodejs,
nodePackages,
# needs to be static and built with MD2 support!
openssl,
pkg-config,
qt5,
runCommand,
nodejs,
onlyoffice-documentserver,
stdenv,
writeScript,
x2t,
}:
@ -104,6 +110,96 @@ let
rev = core-rev;
hash = "sha256-EXeqG8MJWS1asjFihnuMnDSHeKt2x+Ui+8MYK50AnSY=";
};
web-apps = buildNpmPackage (finalAttrs: {
name = "onlyoffice-core-webapps";
#src = /home/aengelen/d/onlyoffice/documentserver/web-apps;
#sourceRoot = "/build/web-apps/build";
src = fetchFromGitHub {
owner = "ONLYOFFICE";
repo = "web-apps";
# rev that the 'web-apps' submodule in documentserver points at
rev = "5255c27b1af64f6edf08d1aba20a23b8149e338c";
hash = "sha256-49v2h+ILQ0X/gNHny6LQcj94A6h7nS99liUAnLRNxzw=";
};
sourceRoot = "${finalAttrs.src.name}/build";
patches = [
./web-apps-avoid-phantomjs.patch
];
npmDepsHash = "sha256-Uen7gl6w/0A4MDk+7j+exkdwfCYqMSPJidad8AM60eQ=";
nativeBuildInputs = [
autoconf
automake
nodePackages.grunt-cli
];
dontNpmBuild = true;
postBuild = ''
chmod u+w ..
mkdir ../deploy
chmod u+w -R ../apps
grunt --force
'';
installPhase = ''
runHook preInstall
cp -r ../deploy/web-apps $out
runHook postInstall
'';
});
sdkjs = buildNpmPackage (finalAttrs: {
name = "onlyoffice-core-sdkjs";
src = fetchFromGitHub {
owner = "ONLYOFFICE";
repo = "sdkjs";
# rev that the 'sdkjs' submodule in documentserver points at
rev = "0e50652cb08c7753a9ab72d0558560ada5d43046";
hash = "sha256-fApr34aT0X8ffPwbsUEWnA3SK8pT5RKNan3YxzhvtAU=";
};
sourceRoot = "${finalAttrs.src.name}/build";
postPatch = ''
cp npm-shrinkwrap.json package-lock.json
'';
npmDepsHash = "sha256-Hpf+z3RGqZ1LTdow6xP00hNmWf4xs+KnVBj4NbPW4uM=";
dontNpmBuild = true;
nativeBuildInputs = [
nodePackages.grunt-cli
jdk
];
postBuild = ''
chmod u+w ..
# the one from node_modules seems a weird hybrid between dynamic and static linking
cp ${closurecompiler}/bin/closure-compiler node_modules/google-closure-compiler-linux/compiler
grunt
'';
installPhase = ''
runHook preInstall
cp -r ../deploy/sdkjs $out
runHook postInstall
'';
});
dictionaries = fetchFromGitHub {
owner = "ONLYOFFICE";
repo = "dictionaries";
tag = "v8.2.0.103";
hash = "sha256-3BwWAvnw0RCD6fxTCRstJSrF5QgfVNVBe8rN1hHhCoU=";
};
buildCoreComponent =
rootdir: attrs:
stdenv.mkDerivation (
@ -630,12 +726,12 @@ buildCoreComponent "X2tConverter/build/Qt" {
mkdir -p $out/etc
cat >$out/etc/DoctRenderer.config <<EOF
<Settings>
<file>${onlyoffice-documentserver}/var/www/onlyoffice/documentserver/sdkjs/common/Native/native.js</file>
<file>${onlyoffice-documentserver}/var/www/onlyoffice/documentserver/sdkjs/common/Native/jquery_native.js</file>
<file>${sdkjs}/common/Native/native.js</file>
<file>${sdkjs}//common/Native/jquery_native.js</file>
<allfonts>${allfonts}/converter/AllFonts.js</allfonts>
<file>${onlyoffice-documentserver}/var/www/onlyoffice/documentserver/web-apps/vendor/xregexp/xregexp-all-min.js</file>
<sdkjs>${onlyoffice-documentserver}/var/www/onlyoffice/documentserver/sdkjs</sdkjs>
<dictionaries>${onlyoffice-documentserver}/var/www/onlyoffice/documentserver/dictionaries</dictionaries>
<file>${web-apps}/vendor/xregexp/xregexp-all-min.js</file>
<sdkjs>${sdkjs}</sdkjs>
<dictionaries>${dictionaries}</dictionaries>
</Settings>
EOF
@ -669,6 +765,9 @@ buildCoreComponent "X2tConverter/build/Qt" {
epubfile
fb2file
iworkfile
web-apps
sdkjs
dictionaries
;
};
meta = {
@ -676,6 +775,6 @@ buildCoreComponent "X2tConverter/build/Qt" {
homepage = "https://github.com/ONLYOFFICE/core/tree/master/X2tConverter";
license = lib.licenses.agpl3Only;
maintainers = with lib.maintainers; [ raboof ];
platforms = lib.platforms.all;
platforms = lib.platforms.linux;
};
}

View File

@ -0,0 +1,12 @@
diff --git a/build/package.json b/build/package.json
index 96b35b328a..f8ec8397b4 100644
--- a/package.json
+++ b/package.json
@@ -45,7 +45,6 @@
},
"devDependencies": {
"chai": "^5.1.0",
- "grunt-mocha": "^1.2.0",
"mocha": "^10.2.0"
}
}