From 6031bb751a06c35935d2e67d88934c99def0eaa8 Mon Sep 17 00:00:00 2001 From: Jeremy Fleischman Date: Fri, 13 Dec 2024 19:56:11 -0800 Subject: [PATCH] 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 d667d349bb5ef891133f6d7b2bc986abfff687c0) --- pkgs/by-name/cr/cryptpad/package.nix | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pkgs/by-name/cr/cryptpad/package.nix b/pkgs/by-name/cr/cryptpad/package.nix index 146e9cf7bc1a..623f57b4f516 100644 --- a/pkgs/by-name/cr/cryptpad/package.nix +++ b/pkgs/by-name/cr/cryptpad/package.nix @@ -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