{ lib, pkgs, config, ... }: let adminer = pkgs.callPackage ../commons/adminer.nix { inherit config; }; cfg = config.myServices.websites.jerome.naturaloutil; varDir = "/var/lib/ftp/jerome"; env = config.myEnv.websites.jerome; apacheUser = config.services.httpd.Prod.user; apacheGroup = config.services.httpd.Prod.group; secretsPath = config.secrets.fullPaths."websites/jerome/naturaloutil"; in { options.myServices.websites.jerome.naturaloutil.enable = lib.mkEnableOption "enable Jerome Naturaloutil's website"; config = lib.mkIf cfg.enable { services.webstats.sites = [ { name = "naturaloutil.immae.eu"; } ]; security.acme.certs."ftp".extraDomainNames = [ "naturaloutil.immae.eu" ]; secrets.keys."websites/jerome/naturaloutil" = { user = apacheUser; group = apacheGroup; permissions = "0400"; text = '' ssl_set(NULL, NULL, "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt", NULL, NULL); '' else ""} $database = connect_db($db, $mysql_server, $mysql_base, $mysql_user, $mysql_password); ?> ''; }; systemd.services.phpfpm-jerome_naturaloutil.after = lib.mkAfter [ "mysql.service" ]; systemd.services.phpfpm-jerome_naturaloutil.wants = [ "mysql.service" ]; services.phpfpm.pools.jerome_naturaloutil = { 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[open_basedir]" = "${secretsPath}:${varDir}:/tmp"; "php_admin_value[session.save_handler]" = "redis"; "php_admin_value[session.save_path]" = "'unix:///run/redis-php-sessions/redis.sock?persistent=1&prefix=Jerome:Naturaloutil:'"; }; phpEnv = { BDD_CONNECT = secretsPath; }; phpPackage = pkgs.php72.withExtensions({ enabled, all }: enabled ++ [all.redis]); }; services.websites.env.production.modules = adminer.apache.modules ++ [ "proxy_fcgi" ]; services.websites.env.production.vhostConfs.jerome_naturaloutil = { certName = "jerome"; certMainHost = "naturaloutil.immae.eu"; hosts = ["naturaloutil.immae.eu" ]; root = varDir; extraConfig = [ (adminer.apache.vhostConf null) '' Use Stats naturaloutil.immae.eu ServerAdmin ${env.server_admin} ErrorLog "${varDir}/logs/error_log" CustomLog "${varDir}/logs/access_log" combined SetHandler "proxy:unix:${config.services.phpfpm.pools.jerome_naturaloutil.socket}|fcgi://localhost" AllowOverride None Require all denied DirectoryIndex index.php index.htm index.html Options Indexes FollowSymLinks MultiViews Includes AllowOverride None Require all granted '' ]; }; }; }