]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - modules/private/websites/librezo/dolibarr_integration.nix
Cloud Installation for librezo
[perso/Immae/Config/Nix.git] / modules / private / websites / librezo / dolibarr_integration.nix
diff --git a/modules/private/websites/librezo/dolibarr_integration.nix b/modules/private/websites/librezo/dolibarr_integration.nix
new file mode 100644 (file)
index 0000000..f8e3bf4
--- /dev/null
@@ -0,0 +1,62 @@
+{ lib, config, pkgs, ... }:
+let
+  cfg = config.myServices.websites.librezo.dolibarrDev;
+  varDir = "/var/lib/ftp/librezo/dolibarr_dev";
+  apacheUser = config.services.httpd.Inte.user;
+  apacheGroup = config.services.httpd.Inte.group;
+in {
+  options.myServices.websites.librezo.dolibarrDev.enable = lib.mkEnableOption "enable Dolibarr website";
+
+  config = lib.mkIf cfg.enable {
+    system.activationScripts.dolibarr = {
+      deps = [ "httpd" "users" ];
+      text = ''
+        install -m 0755 -o ${apacheUser} -g ${apacheGroup} -d /var/lib/php/sessions/librezo
+      '';
+    };
+    services.phpfpm.pools.librezo_dolibarr_dev = {
+      user = apacheUser;
+      group = apacheGroup;
+      settings = {
+        "listen.owner" = apacheUser;
+        "listen.group" = apacheGroup;
+
+        "pm" = "ondemand";
+        "pm.max_children" = "5";
+        "pm.process_idle_timeout" = "60";
+
+        "php_admin_value[upload_max_filesize]" = "100M";
+        "php_admin_value[post_max_size]" = "100M";
+        "php_admin_value[open_basedir]" = "/var/lib/php/sessions/librezo:${varDir}:/tmp";
+        "php_admin_value[session.save_path]" = "/var/lib/php/sessions/librezo";
+      };
+      phpOptions = config.services.phpfpm.phpOptions + ''
+        disable_functions = "mail"
+      '';
+      phpPackage = pkgs.php74;
+    };
+    services.websites.env.production.modules = [ "proxy_fcgi" ];
+    services.websites.env.integration.vhostConfs.librezo_dolibarr_dev = {
+      certName     = "integration";
+      addToCerts   = true;
+      hosts        = ["dolibarr.librezo.immae.dev"];
+      root         = "${varDir}/dolibarr/htdocs";
+      extraConfig  = [
+        ''
+        <FilesMatch "\.php$">
+          SetHandler "proxy:unix:${config.services.phpfpm.pools.librezo_dolibarr_dev.socket}|fcgi://localhost"
+        </FilesMatch>
+
+        <Directory ${varDir}/dolibarr/htdocs>
+          DirectoryIndex index.php index.htm index.html
+          Options Indexes FollowSymLinks MultiViews Includes
+          AllowOverride All
+          Require all granted
+        </Directory>
+          ''
+      ];
+    };
+  };
+}
+
+