]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - virtual/modules/websites/default.nix
Refactor websites.
[perso/Immae/Config/Nix.git] / virtual / modules / websites / default.nix
index b027b81c6671042d86db28ad0397a0e473723e10..6b313811edc46f88004e645ee0fd0bac25f2b7f9 100644 (file)
@@ -91,11 +91,18 @@ in
     ./aten
     ./piedsjaloux
     ./connexionswing
+    ./tools/db
+    ./tools/tools
+    ./tools/dav
+    ./tools/cloud
+    ./tools/git
     # built using:
     # sed -e "s/services\.httpd/services\.httpdProd/g" .nix-defexpr/channels/nixpkgs/nixos/modules/services/web-servers/apache-httpd/default.nix
     # And removed users / groups
     ./apache/httpd_prod.nix
     ./apache/httpd_inte.nix
+    # Adapted from base phpfpm
+    ./phpfpm
   ];
 
   options.services.myWebsites = {
@@ -155,6 +162,12 @@ in
       phpPackages = oldpkgs.php72Packages.override { inherit php; };
     };
 
+    services.myWebsites.tools.databases.enable = true;
+    services.myWebsites.tools.tools.enable = true;
+    services.myWebsites.tools.dav.enable = true;
+    services.myWebsites.tools.cloud.enable = true;
+    services.myWebsites.tools.git.enable = true;
+
     services.myWebsites.Chloe.production.enable = cfg.production.enable;
     services.myWebsites.Ludivine.production.enable = cfg.production.enable;
     services.myWebsites.Aten.production.enable = cfg.production.enable;
@@ -227,6 +240,28 @@ in
       };
     };
 
+    system.activationScripts = {
+      httpd = ''
+        install -d -m 0755 /var/lib/acme/acme-challenge
+        install -d -m 0750 -o wwwrun -g wwwrun /var/lib/php/sessions
+        install -d -m 0750 -o wwwrun -g wwwrun /var/lib/php/sessions/adminer
+        install -d -m 0750 -o wwwrun -g wwwrun /var/lib/php/sessions/mantisbt
+        install -d -m 0750 -o wwwrun -g wwwrun /var/lib/php/sessions/davical
+        '';
+    };
+
+    services.myPhpfpm = {
+      phpPackage = pkgs.php;
+      phpOptions = ''
+        session.save_path = "/var/lib/php/sessions"
+        session.gc_maxlifetime = 60*60*24*15
+        session.cache_expire = 60*24*30
+        '';
+      extraConfig = ''
+        log_level = notice
+        '';
+    };
+
     # FIXME: logrotate
     # FIXME: ipv6
     services.httpdProd = makeService "production" config.services.myWebsites.production;
@@ -238,63 +273,7 @@ in
     services.myWebsites.integration.extraConfig = (builtins.filter (x: x != null) (pkgs.lib.attrsets.mapAttrsToList (n: v: v.extraConfig or null) cfg.apacheConfig));
 
     services.httpd = makeService "tools" config.services.myWebsites.tools;
-    services.myWebsites.tools.modules =
-      mypkgs.adminer.apache.modules ++
-      mypkgs.nextcloud.apache.modules ++
-      mypkgs.ympd.apache.modules ++
-      mypkgs.mantisbt.apache.modules ++
-      mypkgs.ttrss.apache.modules ++
-      mypkgs.roundcubemail.apache.modules ++
-      pkgs.lib.lists.flatten (pkgs.lib.attrsets.mapAttrsToList (n: v: v.modules or []) cfg.apacheConfig);
+    services.myWebsites.tools.modules = pkgs.lib.lists.flatten (pkgs.lib.attrsets.mapAttrsToList (n: v: v.modules or []) cfg.apacheConfig);
     services.myWebsites.tools.extraConfig = (builtins.filter (x: x != null) (pkgs.lib.attrsets.mapAttrsToList (n: v: v.extraConfig or null) cfg.apacheConfig));
-    # FIXME: move them all to separate modules
-    services.myWebsites.tools.vhostConfs.eldiron = {
-      certName    = "eldiron";
-      hosts       = ["eldiron.immae.eu" ];
-      root        = ../../www;
-      extraConfig = [ "DirectoryIndex index.htm" ];
-    };
-    services.myWebsites.tools.vhostConfs.db-1 = {
-      certName    = "eldiron";
-      hosts       = ["db-1.immae.eu" ];
-      root        = null;
-      extraConfig = [ mypkgs.adminer.apache.vhostConf ];
-    };
-    services.myWebsites.tools.vhostConfs.tools = {
-      certName    = "eldiron";
-      hosts       = ["tools.immae.eu" ];
-      root        = null;
-      extraConfig = [
-        mypkgs.adminer.apache.vhostConf
-        mypkgs.ympd.apache.vhostConf
-        mypkgs.ttrss.apache.vhostConf
-        mypkgs.roundcubemail.apache.vhostConf
-      ];
-    };
-    services.myWebsites.tools.vhostConfs.dav = {
-      certName    = "eldiron";
-      hosts       = ["dav.immae.eu" ];
-      root        = null;
-      extraConfig = [
-        mypkgs.infcloud.apache.vhostConf
-        mypkgs.davical.apache.vhostConf
-      ];
-    };
-    services.myWebsites.tools.vhostConfs.cloud = {
-      certName    = "eldiron";
-      hosts       = ["cloud.immae.eu" ];
-      root        = mypkgs.nextcloud.webRoot;
-      extraConfig = [
-        mypkgs.nextcloud.apache.vhostConf
-      ];
-    };
-    services.myWebsites.tools.vhostConfs.git.extraConfig = [
-      mypkgs.mantisbt.apache.vhostConf
-      ''
-        RewriteEngine on
-        RewriteCond %{REQUEST_URI}       ^/releases
-        RewriteRule /releases(.*)        https://release.immae.eu$1 [P,L]
-        ''
-    ];
   };
 }