]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - modules/private/websites/tools/mail/roundcubemail.nix
Use attrs for secrets instead of lists
[perso/Immae/Config/Nix.git] / modules / private / websites / tools / mail / roundcubemail.nix
index 35de312e1beeaa89d00c62b0f4931fd76754169d..92de28ee5a28bc99e907b38ca4ac85533adcc716 100644 (file)
@@ -1,4 +1,4 @@
-{ env, roundcubemail, roundcubemail-plugins, roundcubemail-skins, phpPackages, apacheHttpd }:
+{ env, roundcubemail, apacheHttpd, config }:
 rec {
   varDir = "/var/lib/roundcubemail";
   activationScript = {
@@ -9,8 +9,7 @@ rec {
       install -m 0750 -o ${apache.user} -g ${apache.group} -d ${varDir}/phpSessions
     '';
   };
-  keys = [{
-    dest = "webapps/tools-roundcube";
+  keys."webapps/tools-roundcube" = {
     user = apache.user;
     group = apache.group;
     permissions = "0400";
@@ -74,16 +73,15 @@ rec {
         $config['temp_dir'] = '${varDir}/cache';
         $config['mime_types'] = '${apacheHttpd}/conf/mime.types';
     '';
-  }];
-  webRoot = (roundcubemail.override { roundcube_config = "/var/secrets/webapps/tools-roundcube"; }).withPlugins
-    (builtins.attrValues roundcubemail-plugins) (builtins.attrValues roundcubemail-skins);
+  };
+  webRoot = (roundcubemail.override { roundcube_config = config.secrets.fullPaths."webapps/tools-roundcube"; }).withPlugins (p: [ p.automatic_addressbook p.carddav p.contextmenu p.contextmenu_folder p.html5_notifier p.ident_switch p.message_highlight p.thunderbird_labels ]);
   apache = rec {
     user = "wwwrun";
     group = "wwwrun";
     modules = [ "proxy_fcgi" ];
     webappName = "tools_roundcubemail";
     root = "/run/current-system/webapps/${webappName}";
-    vhostConf = ''
+    vhostConf = socket: ''
     Alias /roundcube "${root}"
     <Directory "${root}">
         DirectoryIndex index.php
@@ -92,7 +90,7 @@ rec {
         Require all granted
 
         <FilesMatch "\.php$">
-          SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
+          SetHandler "proxy:unix:${socket}|fcgi://localhost"
         </FilesMatch>
       </Directory>
       '';
@@ -100,29 +98,22 @@ rec {
   phpFpm = rec {
     serviceDeps = [ "postgresql.service" ];
     basedir = builtins.concatStringsSep ":" (
-      [ webRoot "/var/secrets/webapps/tools-roundcube" varDir ]
+      [ webRoot config.secrets.fullPaths."webapps/tools-roundcube" varDir ]
       ++ webRoot.plugins
       ++ webRoot.skins);
-    phpConfig = ''
-      date.timezone = 'CET'
-      extension=${phpPackages.imagick}/lib/php/extensions/imagick.so
-      '';
-    socket = "/var/run/phpfpm/roundcubemail.sock";
-    pool = ''
-      user = ${apache.user}
-      group = ${apache.group}
-      listen.owner = ${apache.user}
-      listen.group = ${apache.group}
-      pm = ondemand
-      pm.max_children = 60
-      pm.process_idle_timeout = 60
+    pool = {
+      "listen.owner" = apache.user;
+      "listen.group" = apache.group;
+      "pm" = "ondemand";
+      "pm.max_children" = "60";
+      "pm.process_idle_timeout" = "60";
 
-      ; Needed to avoid clashes in browser cookies (same domain)
-      php_value[session.name] = RoundcubemailPHPSESSID
-      php_admin_value[upload_max_filesize] = 200M
-      php_admin_value[post_max_size] = 200M
-      php_admin_value[open_basedir] = "${basedir}:${apacheHttpd}/conf/mime.types:/tmp"
-      php_admin_value[session.save_path] = "${varDir}/phpSessions"
-      '';
+      # Needed to avoid clashes in browser cookies (same domain)
+      "php_value[session.name]" = "RoundcubemailPHPSESSID";
+      "php_admin_value[upload_max_filesize]" = "200M";
+      "php_admin_value[post_max_size]" = "200M";
+      "php_admin_value[open_basedir]" = "${basedir}:${apacheHttpd}/conf/mime.types:/tmp";
+      "php_admin_value[session.save_path]" = "${varDir}/phpSessions";
+    };
   };
 }