From ed26b7b0c374e946dbd774e00d7f0aa1b8fde87f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Fri, 4 Apr 2025 11:37:33 +0200 Subject: [PATCH 1/2] nixos/onlyoffice: misc cleanup --- nixos/modules/services/web-apps/onlyoffice.nix | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/nixos/modules/services/web-apps/onlyoffice.nix b/nixos/modules/services/web-apps/onlyoffice.nix index 5d2e03147a68..48e51b13bb39 100644 --- a/nixos/modules/services/web-apps/onlyoffice.nix +++ b/nixos/modules/services/web-apps/onlyoffice.nix @@ -114,7 +114,7 @@ in proxy_pass http://onlyoffice-docservice/$2$3; ''; # /etc/nginx/includes/ds-docservice.conf - #disable caching for api.js + # disable caching for api.js "~ ^(\\/[\\d]+\\.[\\d]+\\.[\\d]+[\\.|-][\\w]+)?\\/(web-apps\\/apps\\/api\\/documents\\/api\\.js)$".extraConfig = '' expires -1; @@ -124,26 +124,23 @@ in "~ ^(\\/[\\d]+\\.[\\d]+\\.[\\d]+[\\.|-][\\w]+)?\\/(document_editor_service_worker\\.js)$".extraConfig = '' expires 365d; - # gzip_static on; - alias ${cfg.package}/var/www/onlyoffice/documentserver/sdkjs/common/serviceworker/$2; + alias ${cfg.package}/var/www/onlyoffice/documentserver/sdkjs/common/serviceworker/$2; ''; - #suppress logging the unsupported locale error in web-apps + # suppress logging the unsupported locale error in web-apps "~ ^(\\/[\\d]+\\.[\\d]+\\.[\\d]+[\\.|-][\\w]+)?\\/(web-apps)(\\/.*\\.json)$".extraConfig = '' expires 365d; error_log /dev/null crit; alias ${cfg.package}/var/www/onlyoffice/documentserver/$2$3; ''; - #suppress logging the unsupported locale error in plugins + # suppress logging the unsupported locale error in plugins "~ ^(\\/[\\d]+\\.[\\d]+\\.[\\d]+[\\.|-][\\w]+)?\\/(sdkjs-plugins)(\\/.*\\.json)$".extraConfig = '' expires 365d; error_log /dev/null crit; - # gzip_static on; alias ${cfg.package}/var/www/onlyoffice/documentserver/$2$3; ''; "~ ^(\\/[\\d]+\\.[\\d]+\\.[\\d]+[\\.|-][\\w]+)?\\/(web-apps|sdkjs|sdkjs-plugins|fonts|dictionaries)(\\/.*)$".extraConfig = '' expires 365d; - # gzip_static on; alias ${cfg.package}/var/www/onlyoffice/documentserver/$2$3; ''; "~* ^(\\/cache\\/files.*)(\\/.*)".extraConfig = '' @@ -302,9 +299,8 @@ in ' /run/onlyoffice/config/default.json | sponge /run/onlyoffice/config/default.json chmod u+w /run/onlyoffice/config/production-linux.json - jq ' - .FileConverter.converter.x2tPath = "${cfg.x2t}/bin/x2t" - ' /run/onlyoffice/config/production-linux.json | sponge /run/onlyoffice/config/production-linux.json + jq '.FileConverter.converter.x2tPath = "${cfg.x2t}/bin/x2t"' \ + /run/onlyoffice/config/production-linux.json | sponge /run/onlyoffice/config/production-linux.json if psql -d onlyoffice -c "SELECT 'task_result'::regclass;" >/dev/null; then psql -f ${cfg.package}/var/www/onlyoffice/documentserver/server/schema/postgresql/removetbl.sql From dbb3bdb4d4d981692cefe88436eb36f3a59f9d96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Fri, 4 Apr 2025 11:37:49 +0200 Subject: [PATCH 2/2] onlyoffice-documentserver: fail loudly when HASH_POSTFIX would change --- pkgs/by-name/on/onlyoffice-documentserver/package.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/by-name/on/onlyoffice-documentserver/package.nix b/pkgs/by-name/on/onlyoffice-documentserver/package.nix index a86bf31a641f..0d828b87580c 100644 --- a/pkgs/by-name/on/onlyoffice-documentserver/package.nix +++ b/pkgs/by-name/on/onlyoffice-documentserver/package.nix @@ -61,9 +61,9 @@ let mkdir -p var/lib/onlyoffice/ var/www/onlyoffice/documentserver/fonts/ # see usr/bin/documentserver-flush-cache.sh - cp var/www/onlyoffice/documentserver/web-apps/apps/api/documents/api.js.tpl var/www/onlyoffice/documentserver/web-apps/apps/api/documents/api.js - HASH=$(basename $out | cut -d '-' -f 1) - sed -i "s/{{HASH_POSTFIX}}/$HASH/g" var/www/onlyoffice/documentserver/web-apps/apps/api/documents/api.js + cp var/www/onlyoffice/documentserver/web-apps/apps/api/documents/api.js{.tpl,} + substituteInPlace var/www/onlyoffice/documentserver/web-apps/apps/api/documents/api.js \ + --replace-fail '{{HASH_POSTFIX}}' "$(basename $out | cut -d '-' -f 1)" mv * $out/ '';