{ lib, config, pkgs, ... }: let cfg = config.myServices.websites.librezo.dolibarr; varDir = "/var/lib/ftp/librezo/dolibarr"; apacheUser = config.services.httpd.Prod.user; apacheGroup = config.services.httpd.Prod.group; in { options.myServices.websites.librezo.dolibarr.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 = { 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.production.vhostConfs.librezo_dolibarr = { certName = "librezo"; addToCerts = true; hosts = ["dolibarr.librezo.com"]; root = "${varDir}/dolibarr/htdocs"; extraConfig = [ '' SetHandler "proxy:unix:${config.services.phpfpm.pools.librezo_dolibarr.socket}|fcgi://localhost" DirectoryIndex index.php index.htm index.html Options Indexes FollowSymLinks MultiViews Includes AllowOverride All Require all granted '' ]; }; }; }