]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - modules/private/websites/emilia/atelierfringant.nix
Add website for AtelierFringant
[perso/Immae/Config/Nix.git] / modules / private / websites / emilia / atelierfringant.nix
diff --git a/modules/private/websites/emilia/atelierfringant.nix b/modules/private/websites/emilia/atelierfringant.nix
new file mode 100644 (file)
index 0000000..b47452f
--- /dev/null
@@ -0,0 +1,65 @@
+{ lib, pkgs, config,  ... }:
+let
+  cfg = config.myServices.websites.emilia.atelierfringant;
+  varDir = "/var/lib/ftp/emilia/atelierfringant";
+  apacheUser = config.services.httpd.Prod.user;
+  apacheGroup = config.services.httpd.Prod.group;
+in {
+  options.myServices.websites.emilia.atelierfringant.enable = lib.mkEnableOption "enable Ă‰milia's website";
+
+  config = lib.mkIf cfg.enable {
+    system.activationScripts.emilia_atelierfringant = {
+      deps = [ "httpd" ];
+      text = ''
+        install -m 0755 -o ${apacheUser} -g ${apacheGroup} -d /var/lib/ftp/emilia/atelierfringant
+        install -m 0755 -o ${apacheUser} -g ${apacheGroup} -d /var/lib/php/sessions/emilia
+        '';
+    };
+    systemd.services.phpfpm-emilia_atelierfringant.after = lib.mkAfter [ "mysql.service" ];
+    systemd.services.phpfpm-emilia_atelierfringant.wants = [ "mysql.service" ];
+    services.phpfpm.pools.emilia_atelierfringant = {
+      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]" = "/var/lib/php/sessions/emilia:${varDir}:/tmp";
+        "php_admin_value[session.save_path]" = "/var/lib/php/sessions/emilia";
+      };
+      phpOptions = config.services.phpfpm.phpOptions + ''
+        disable_functions = "mail"
+      '';
+      phpPackage = pkgs.php72;
+    };
+    services.websites.env.production.modules = [ "proxy_fcgi" ];
+    services.websites.env.production.vhostConfs.emilia_atelierfringant = {
+      certName     = "emilia";
+      certMainHost = "atelierfringant.org";
+      hosts        = ["atelierfringant.org" "www.atelierfringant.org" ];
+      root         = varDir;
+      extraConfig  = [
+        ''
+        <FilesMatch "\.php$">
+          SetHandler "proxy:unix:${config.services.phpfpm.pools.emilia_atelierfringant.socket}|fcgi://localhost"
+        </FilesMatch>
+
+        <Location /xmlrpc.php>
+          AllowOverride None
+          Require all denied
+        </Location>
+        <Directory ${varDir}>
+          DirectoryIndex index.php index.htm index.html
+          Options Indexes FollowSymLinks MultiViews Includes
+          AllowOverride all
+          Require all granted
+        </Directory>
+          ''
+      ];
+    };
+  };
+}