From 046ae67083046cfeb9e65b98e569446fd2f0679b Mon Sep 17 00:00:00 2001 From: ibizaman Date: Thu, 29 Feb 2024 21:54:45 -0800 Subject: [PATCH] optionally make nextcloud systemd services depend on mount point --- modules/services/nextcloud-server.nix | 17 ++++++++++++++++- .../services/nextcloud-server/docs/default.md | 12 ++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/modules/services/nextcloud-server.nix b/modules/services/nextcloud-server.nix index b0199b3..197f251 100644 --- a/modules/services/nextcloud-server.nix +++ b/modules/services/nextcloud-server.nix @@ -82,6 +82,13 @@ in default = "/var/lib/nextcloud"; }; + mountPointServices = lib.mkOption { + description = "If given, all the systemd services and timers will depend on the specified mount point systemd services."; + type = lib.types.listOf lib.types.str; + default = []; + example = lib.literalExpression ''["var.mount"]''; + }; + adminUser = lib.mkOption { type = lib.types.str; description = "Username of the initial admin user."; @@ -616,10 +623,17 @@ in systemd.services.phpfpm-nextcloud.preStart = '' mkdir -p /var/log/xdebug; chown -R nextcloud: /var/log/xdebug ''; + systemd.services.phpfpm-nextcloud.requires = cfg.mountPointServices; + systemd.services.phpfpm-nextcloud.after = cfg.mountPointServices; systemd.services.nextcloud-cron.path = [ pkgs.perl ]; + systemd.timers.nextcloud-cron.requires = cfg.mountPointServices; + systemd.timers.nextcloud-cron.after = cfg.mountPointServices; + + systemd.services.nextcloud-setup.requires = cfg.mountPointServices; + systemd.services.nextcloud-setup.after = cfg.mountPointServices; # Sets up backup for Nextcloud. shb.backup.instances.nextcloud = { @@ -685,7 +699,8 @@ in # Configured as defined in https://github.com/nextcloud/previewgenerator systemd.timers.nextcloud-cron-previewgenerator = { wantedBy = [ "timers.target" ]; - after = [ "nextcloud-setup.service" ]; + requires = cfg.mountPointServices; + after = [ "nextcloud-setup.service" ] + cfg.mountPointServices; timerConfig.OnBootSec = "10m"; timerConfig.OnUnitActiveSec = "10m"; timerConfig.Unit = "nextcloud-cron-previewgenerator.service"; diff --git a/modules/services/nextcloud-server/docs/default.md b/modules/services/nextcloud-server/docs/default.md index 5a28cd2..d89e2f1 100644 --- a/modules/services/nextcloud-server/docs/default.md +++ b/modules/services/nextcloud-server/docs/default.md @@ -83,6 +83,18 @@ shb.nextcloud = { After deploying, the Nextcloud server will be reachable at `http://nextcloud.example.com`. +### Mount Point {#services-nextcloud-server-mount-point} + +If the `dataDir` exists in a mount point, it is highly recommended to make the various Nextcloud +services wait on the mount point before starting. Doing that is just a matter of setting the `mountPointServices` option. + +Assuming a mount point on `/var`, the configuration would look like so: + +```nix +fileSystems."/var".device = "..."; +shb.nextcloud.mountPointServices = [ "var.mount" ]; +``` + ### With LDAP Support {#services-nextcloud-server-usage-ldap} :::: {.note}