cryptpad: add missing x2t.js

This dependency is necessary for cryptpad to convert between various
document formats. I ran into this when trying to import a `.xlsx` file
into cryptpad.

This code was inspired by the [`install_x2t` function in upstream's
`install-onlyoffice.sh` script](https://github.com/cryptpad/cryptpad/blob/2024.9.1/install-onlyoffice.sh#L37).

(cherry picked from commit d667d349bb)
This commit is contained in:
Jeremy Fleischman
2024-12-13 19:56:11 -08:00
committed by github-actions[bot]
parent 595c22cce5
commit 6031bb751a

View File

@@ -1,11 +1,13 @@
{
buildNpmPackage,
fetchFromGitHub,
fetchurl,
lib,
makeBinaryWrapper,
nixosTests,
nodejs,
rdfind,
unzip,
}:
let
@@ -59,6 +61,17 @@ let
}
];
x2t_version = "v7.3+1";
x2t = fetchurl {
url = "https://github.com/cryptpad/onlyoffice-x2t-wasm/releases/download/${x2t_version}/x2t.zip";
hash = "sha256-hrbxrI8RC1pBatGZ76TAiVfUbZid7+eRuXk6lmz7OgQ=";
};
x2t_install = ''
local X2T_DIR=$out_cryptpad/www/common/onlyoffice/dist/x2t
unzip ${x2t} -d "$X2T_DIR"
echo "${x2t_version}" > "$X2T_DIR"/.version
'';
in
buildNpmPackage {
inherit version;
@@ -76,6 +89,7 @@ buildNpmPackage {
nativeBuildInputs = [
makeBinaryWrapper
rdfind
unzip
];
patches = [
@@ -106,6 +120,7 @@ buildNpmPackage {
# install OnlyOffice (install-onlyoffice.sh without network)
mkdir -p "$out_cryptpad/www/common/onlyoffice/dist"
${lib.concatMapStringsSep "\n" onlyoffice_install onlyoffice_versions}
${x2t_install}
rdfind -makehardlinks true -makeresultsfile false "$out_cryptpad/www/common/onlyoffice/dist"
# cryptpad assumes it runs in the source directory and also outputs