summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authortalyz <kim.lindberger@gmail.com>2022-01-11 13:19:51 +0100
committertalyz <kim.lindberger@gmail.com>2022-01-18 15:16:04 +0100
commite7fa7fdffc8c37239fb98e1d902a932cad066ea5 (patch)
tree8595a0c5261566fbaf7ff14d1103615044214c16 /nixos
parent97922bf97ea19a262e7ee4b9b71b4692372b87d8 (diff)
downloadnixpkgs-e7fa7fdffc8c37239fb98e1d902a932cad066ea5.tar
nixpkgs-e7fa7fdffc8c37239fb98e1d902a932cad066ea5.tar.gz
nixpkgs-e7fa7fdffc8c37239fb98e1d902a932cad066ea5.tar.bz2
nixpkgs-e7fa7fdffc8c37239fb98e1d902a932cad066ea5.tar.lz
nixpkgs-e7fa7fdffc8c37239fb98e1d902a932cad066ea5.tar.xz
nixpkgs-e7fa7fdffc8c37239fb98e1d902a932cad066ea5.tar.zst
nixpkgs-e7fa7fdffc8c37239fb98e1d902a932cad066ea5.zip
nixos/bookstack: Clear the cache more reliably
When upgrading bookstack, if something in the cache conflicts with the
new installation, the artisan commands might fail. To solve this, make
the cache lifetime bound to the setup service. This also removes the
`cacheDir` option, since the path is now handled automatically by
systemd.
Diffstat (limited to 'nixos')
-rw-r--r--nixos/doc/manual/from_md/release-notes/rl-2205.section.xml7
-rw-r--r--nixos/doc/manual/release-notes/rl-2205.section.md3
-rw-r--r--nixos/modules/services/web-apps/bookstack.nix29
3 files changed, 22 insertions, 17 deletions
diff --git a/nixos/doc/manual/from_md/release-notes/rl-2205.section.xml b/nixos/doc/manual/from_md/release-notes/rl-2205.section.xml
index 932d60d6b36..705d28aad5d 100644
--- a/nixos/doc/manual/from_md/release-notes/rl-2205.section.xml
+++ b/nixos/doc/manual/from_md/release-notes/rl-2205.section.xml
@@ -391,6 +391,13 @@
           <literal>reloadIfChanged</literal> of the units.
         </para>
       </listitem>
+      <listitem>
+        <para>
+          The <literal>services.bookstack.cacheDir</literal> option has
+          been removed, since the cache directory is now handled by
+          systemd.
+        </para>
+      </listitem>
     </itemizedlist>
   </section>
   <section xml:id="sec-release-22.05-notable-changes">
diff --git a/nixos/doc/manual/release-notes/rl-2205.section.md b/nixos/doc/manual/release-notes/rl-2205.section.md
index 7e97bd06676..70691ccce87 100644
--- a/nixos/doc/manual/release-notes/rl-2205.section.md
+++ b/nixos/doc/manual/release-notes/rl-2205.section.md
@@ -122,6 +122,9 @@ In addition to numerous new and upgraded packages, this release has the followin
 
 - The interface that allows activation scripts to restart units has been reworked. Restarting and reloading is now done by a single file `/run/nixos/activation-restart-list` that honors `restartIfChanged` and `reloadIfChanged` of the units.
 
+- The `services.bookstack.cacheDir` option has been removed, since the
+  cache directory is now handled by systemd.
+
 ## Other Notable Changes {#sec-release-22.05-notable-changes}
 
 - The option [services.redis.servers](#opt-services.redis.servers) was added
diff --git a/nixos/modules/services/web-apps/bookstack.nix b/nixos/modules/services/web-apps/bookstack.nix
index b509e4fff45..1124568e8d3 100644
--- a/nixos/modules/services/web-apps/bookstack.nix
+++ b/nixos/modules/services/web-apps/bookstack.nix
@@ -26,6 +26,10 @@ let
 
 
 in {
+  imports = [
+    (mkRemovedOptionModule [ "services" "bookstack" "cacheDir" ] "The cache directory is now handled automatically.")
+  ];
+
   options.services.bookstack = {
 
     enable = mkEnableOption "BookStack";
@@ -60,12 +64,6 @@ in {
       type = types.str;
     };
 
-    cacheDir = mkOption {
-      description = "BookStack cache directory";
-      default = "/var/cache/bookstack";
-      type = types.path;
-    };
-
     dataDir = mkOption {
       description = "BookStack data directory";
       default = "/var/lib/bookstack";
@@ -290,8 +288,11 @@ in {
       wantedBy = [ "multi-user.target" ];
       serviceConfig = {
         Type = "oneshot";
+        RemainAfterExit = true;
         User = user;
         WorkingDirectory = "${bookstack}";
+        RuntimeDirectory = "bookstack/cache";
+        RuntimeDirectoryMode = 0700;
       };
       script = ''
         # set permissions
@@ -313,27 +314,21 @@ in {
         ${optionalString (mail.encryption != null) "MAIL_ENCRYPTION=${mail.encryption};"}
         ${optionalString (db.passwordFile != null) "DB_PASSWORD=$(head -n1 ${db.passwordFile})"}
         ${optionalString (mail.passwordFile != null) "MAIL_PASSWORD=$(head -n1 ${mail.passwordFile})"}
-        APP_SERVICES_CACHE=${cfg.cacheDir}/services.php
-        APP_PACKAGES_CACHE=${cfg.cacheDir}/packages.php
-        APP_CONFIG_CACHE=${cfg.cacheDir}/config.php
-        APP_ROUTES_CACHE=${cfg.cacheDir}/routes-v7.php
-        APP_EVENTS_CACHE=${cfg.cacheDir}/events.php
+        APP_SERVICES_CACHE=/run/bookstack/cache/services.php
+        APP_PACKAGES_CACHE=/run/bookstack/cache/packages.php
+        APP_CONFIG_CACHE=/run/bookstack/cache/config.php
+        APP_ROUTES_CACHE=/run/bookstack/cache/routes-v7.php
+        APP_EVENTS_CACHE=/run/bookstack/cache/events.php
         ${optionalString (cfg.nginx.addSSL || cfg.nginx.forceSSL || cfg.nginx.onlySSL || cfg.nginx.enableACME) "SESSION_SECURE_COOKIE=true"}
         ${toString cfg.extraConfig}
         " > "${cfg.dataDir}/.env"
 
         # migrate db
         ${pkgs.php}/bin/php artisan migrate --force
-
-        # clear & create caches (needed in case of update)
-        ${pkgs.php}/bin/php artisan cache:clear
-        ${pkgs.php}/bin/php artisan config:clear
-        ${pkgs.php}/bin/php artisan view:clear
       '';
     };
 
     systemd.tmpfiles.rules = [
-      "d ${cfg.cacheDir}                           0700 ${user} ${group} - -"
       "d ${cfg.dataDir}                            0710 ${user} ${group} - -"
       "d ${cfg.dataDir}/public                     0750 ${user} ${group} - -"
       "d ${cfg.dataDir}/public/uploads             0750 ${user} ${group} - -"