diff --git a/nixos/modules/services/web-apps/nextcloud.nix b/nixos/modules/services/web-apps/nextcloud.nix index 1e9360dc1f925..f7f55743d5c95 100644 --- a/nixos/modules/services/web-apps/nextcloud.nix +++ b/nixos/modules/services/web-apps/nextcloud.nix @@ -12,9 +12,11 @@ let cfg = config.services.nextcloud; - overridePackage = cfg.package.override { - inherit (config.security.pki) caBundle; - }; + overridePackage = + (if cfg.enableCompressedAssets then cfg.package.passthru.compressed else cfg.package).override + { + inherit (config.security.pki) caBundle; + }; fpm = config.services.phpfpm.pools.nextcloud; @@ -422,6 +424,11 @@ in Set this to false to disable the installation of apps from the global appstore. App management is always enabled regardless of this setting. ''; }; + enableCompressedAssets = lib.mkOption { + type = lib.types.bool; + default = true; + description = "Whether to use gzip, brotli and zstd pre-compressed artifacts for lower CPU usage and transfer size but bigger storage size."; + }; https = lib.mkOption { type = lib.types.bool; default = false; @@ -448,7 +455,7 @@ in type = lib.types.package; readOnly = true; description = '' - Package to the finalized Nextcloud package, including all installed apps. + Package to the finalized Nextcloud package, including all installed apps and potentially pre-compressed assets. This is automatically set by the module. ''; }; diff --git a/pkgs/servers/nextcloud/default.nix b/pkgs/servers/nextcloud/default.nix index 145708bc4fdfe..13a7cf66733c2 100644 --- a/pkgs/servers/nextcloud/default.nix +++ b/pkgs/servers/nextcloud/default.nix @@ -7,6 +7,7 @@ caBundle ? "${cacert}/etc/ssl/certs/ca-bundle.crt", nextcloud30Packages, nextcloud31Packages, + compressDrvWeb, }: let @@ -18,44 +19,56 @@ let extraVulnerabilities ? [ ], packages, }: - stdenvNoCC.mkDerivation rec { - pname = "nextcloud"; - inherit version; + let + basePackage = stdenvNoCC.mkDerivation rec { + pname = "nextcloud"; + inherit version; - src = fetchurl { - url = "https://download.nextcloud.com/server/releases/nextcloud-${version}.tar.bz2"; - inherit hash; - }; + src = fetchurl { + url = "https://download.nextcloud.com/server/releases/nextcloud-${version}.tar.bz2"; + inherit hash; + }; - passthru = { - tests = lib.filterAttrs ( - key: _: (lib.hasSuffix (lib.versions.major version) key) - ) nixosTests.nextcloud; - inherit packages; - }; + passthru = { + tests = lib.filterAttrs ( + key: _: (lib.hasSuffix (lib.versions.major version) key) + ) nixosTests.nextcloud; + inherit packages; + compressed = compressed; + }; - postPatch = '' - cp ${caBundle} resources/config/ca-bundle.crt - ''; + postPatch = '' + cp ${caBundle} resources/config/ca-bundle.crt + ''; - installPhase = '' - runHook preInstall - mkdir -p $out/ - cp -R . $out/ - runHook postInstall - ''; + installPhase = '' + runHook preInstall + mkdir -p $out/ + cp -R . $out/ + runHook postInstall + ''; - meta = { - changelog = "https://nextcloud.com/changelog/#${lib.replaceStrings [ "." ] [ "-" ] version}"; - description = "Sharing solution for files, calendars, contacts and more"; - homepage = "https://nextcloud.com"; - teams = [ lib.teams.nextcloud ]; - license = lib.licenses.agpl3Plus; - platforms = lib.platforms.linux; - knownVulnerabilities = - extraVulnerabilities ++ (lib.optional eol "Nextcloud version ${version} is EOL"); + meta = { + changelog = "https://nextcloud.com/changelog/#${lib.replaceStrings [ "." ] [ "-" ] version}"; + description = "Sharing solution for files, calendars, contacts and more"; + homepage = "https://nextcloud.com"; + teams = [ lib.teams.nextcloud ]; + license = lib.licenses.agpl3Plus; + platforms = lib.platforms.linux; + knownVulnerabilities = + extraVulnerabilities ++ (lib.optional eol "Nextcloud version ${version} is EOL"); + }; }; - }; + compressed = (compressDrvWeb basePackage { }).overrideAttrs ( + { passthru, ... }: + { + passthru = passthru // { + override = compressed; + }; + } + ); + in + basePackage; in { nextcloud30 = generic {