From ab9b8f8cf4165e8fdd7d2b50b459832ec0069b4d Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Sat, 22 Jun 2024 18:38:04 +0200 Subject: nixos/nextcloud: `services.nextcloud.occ` is not internal This option is actually useful when having a systemd unit invoking `nextcloud-occ`, then you want to do something like path = [ config.services.nextcloud.occ ] This is possible today, but not documented (and the option completion from nil doesn't pick it up as a result). --- nixos/modules/services/web-apps/nextcloud.nix | 1 - 1 file changed, 1 deletion(-) (limited to 'nixos') diff --git a/nixos/modules/services/web-apps/nextcloud.nix b/nixos/modules/services/web-apps/nextcloud.nix index d7eb2c6cb734f..a7a3d01f1f450 100644 --- a/nixos/modules/services/web-apps/nextcloud.nix +++ b/nixos/modules/services/web-apps/nextcloud.nix @@ -642,7 +642,6 @@ in { type = types.package; default = occ; defaultText = literalMD "generated script"; - internal = true; description = '' The nextcloud-occ program preconfigured to target this Nextcloud instance. ''; -- cgit 1.4.1 From 50d5306e7c28085420cde8c533464ea8921e0e37 Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Sat, 22 Jun 2024 18:39:08 +0200 Subject: nixos/nextcloud: use dedicated memory limit for the entire CLI Originally, I wanted to execute `nextcloud-occ` with a higher memory limit because I needed to trigger an expensive operation by hand, regenerating a bunch of previews. While doing so, I realized how painful it is to put an invocation of nextcloud-occ together for that, especially when you need to put it into another systemd unit in Nix code. That's why I decided to use the memory limit now for every CLI invocation just in case. The stuff you do in those units (e.g. running background jobs) is something you can also do by hand with `nextcloud-occ` and you'll most likely want to have the same memory limit there. --- nixos/modules/services/web-apps/nextcloud.nix | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'nixos') diff --git a/nixos/modules/services/web-apps/nextcloud.nix b/nixos/modules/services/web-apps/nextcloud.nix index a7a3d01f1f450..8d18c8e973915 100644 --- a/nixos/modules/services/web-apps/nextcloud.nix +++ b/nixos/modules/services/web-apps/nextcloud.nix @@ -80,6 +80,12 @@ let mkKeyValue = generators.mkKeyValueDefault {} " = "; }; + phpCli = concatStringsSep " " ([ + "${getExe phpPackage}" + ] ++ optionals (cfg.cli.memoryLimit != null) [ + "-dmemory_limit=${cfg.cli.memoryLimit}" + ]); + occ = pkgs.writeScriptBin "nextcloud-occ" '' #! ${pkgs.runtimeShell} cd ${webroot} @@ -89,7 +95,7 @@ let fi export NEXTCLOUD_CONFIG_DIR="${datadir}/config" $sudo \ - ${phpPackage}/bin/php \ + ${phpCli} \ occ "$@" ''; @@ -196,6 +202,9 @@ let in { imports = [ + (mkRenamedOptionModule + [ "services" "nextcloud" "cron" "memoryLimit" ] + [ "services" "nextcloud" "cli" "memoryLimit" ]) (mkRemovedOptionModule [ "services" "nextcloud" "enableBrokenCiphersForSSE" ] '' This option has no effect since there's no supported Nextcloud version packaged here using OpenSSL for RC4 SSE. @@ -793,7 +802,7 @@ in { }; }; - cron.memoryLimit = mkOption { + cli.memoryLimit = mkOption { type = types.nullOr types.str; default = null; example = "1G"; @@ -1009,14 +1018,8 @@ in { serviceConfig = { Type = "exec"; User = "nextcloud"; - ExecCondition = "${lib.getExe phpPackage} -f ${webroot}/occ status -e"; - ExecStart = lib.concatStringsSep " " ([ - (lib.getExe phpPackage) - ] ++ optional (cfg.cron.memoryLimit != null) "-dmemory_limit=${cfg.cron.memoryLimit}" - ++ [ - "-f" - "${webroot}/cron.php" - ]); + ExecCondition = "${phpCli} -f ${webroot}/occ status -e"; + ExecStart = "${phpCli} -f ${webroot}/cron.php"; KillMode = "process"; }; }; @@ -1040,7 +1043,7 @@ in { serviceConfig = { Type = "exec"; User = "nextcloud"; - ExecCondition = "${lib.getExe phpPackage} -f ${webroot}/occ status -e"; + ExecCondition = "${phpCli} -f ${webroot}/occ status -e"; }; }; }; -- cgit 1.4.1