From d0d94e61c87771e4afcfcf095cd8e626eb6fb0ef Mon Sep 17 00:00:00 2001 From: ibizaman Date: Thu, 29 Feb 2024 20:39:51 -0800 Subject: [PATCH] use better defaults for nextcloud preview app --- modules/services/nextcloud-server.nix | 33 +++++++++++++++++++ .../services/nextcloud-server/docs/default.md | 9 +++++ 2 files changed, 42 insertions(+) diff --git a/modules/services/nextcloud-server.nix b/modules/services/nextcloud-server.nix index e0a4f2a..3c2943e 100644 --- a/modules/services/nextcloud-server.nix +++ b/modules/services/nextcloud-server.nix @@ -239,6 +239,27 @@ in options = { enable = lib.mkEnableOption "Nextcloud Preview Generator App"; + recommendedSettings = lib.mkOption { + type = lib.types.bool; + description = '' + Better defaults than the defaults. Taken from [this article](http://web.archive.org/web/20200513043150/https://ownyourbits.com/2019/06/29/understanding-and-improving-nextcloud-previews/). + + Sets the following options: + + ``` + nextcloud-occ config:app:set previewgenerator squareSizes --value="32 256" + nextcloud-occ config:app:set previewgenerator widthSizes --value="256 384" + nextcloud-occ config:app:set previewgenerator heightSizes --value="256" + nextcloud-occ config:system:set preview_max_x --value 2048 + nextcloud-occ config:system:set preview_max_y --value 2048 + nextcloud-occ config:system:set jpeg_quality --value 60 + nextcloud-occ config:app:set preview jpeg_quality --value="60" + ``` + ''; + default = true; + example = false; + }; + debug = lib.mkOption { type = lib.types.bool; description = "Enable more verbose logging."; @@ -649,6 +670,18 @@ in inherit ((nextcloudApps cfg.version)) previewgenerator; }; + # Values taken from + # http://web.archive.org/web/20200513043150/https://ownyourbits.com/2019/06/29/understanding-and-improving-nextcloud-previews/ + systemd.services.nextcloud-setup.script = lib.mkIf cfg.apps.previewgenerator.recommendedSettings '' + ${occ} config:app:set previewgenerator squareSizes --value="32 256" + ${occ} config:app:set previewgenerator widthSizes --value="256 384" + ${occ} config:app:set previewgenerator heightSizes --value="256" + ${occ} config:system:set preview_max_x --value 2048 + ${occ} config:system:set preview_max_y --value 2048 + ${occ} config:system:set jpeg_quality --value 60 + ${occ} config:app:set preview jpeg_quality --value="60" + ''; + # Configured as defined in https://github.com/nextcloud/previewgenerator systemd.timers.nextcloud-cron-previewgenerator = { wantedBy = [ "timers.target" ]; diff --git a/modules/services/nextcloud-server/docs/default.md b/modules/services/nextcloud-server/docs/default.md index faf7191..3f293ed 100644 --- a/modules/services/nextcloud-server/docs/default.md +++ b/modules/services/nextcloud-server/docs/default.md @@ -281,6 +281,15 @@ Note that you still need to generate the previews for any pre-existing files wit nextcloud-occ -vvv preview:generate-all ``` +The default settings generates all possible sizes which is a waste since most are not used. SHB will +change the generation settings to optimize disk space and CPU usage as outlined in [this +article](http://web.archive.org/web/20200513043150/https://ownyourbits.com/2019/06/29/understanding-and-improving-nextcloud-previews/). +You can opt-out with: + +```nix +shb.nextcloud.apps.previewgenerator.recommendedSettings = false; +``` + ### Enable OnlyOffice App {#services-nextcloud-server-usage-onlyoffice} The following snippet installs and enables the [Only