]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - modules/private/websites/chloe/production.nix
Upgrade nixos
[perso/Immae/Config/Nix.git] / modules / private / websites / chloe / production.nix
index 0eafebdc6e76d41160b8b5f8527252536ed52deb..83f6c9b6a07720ffc9bb783c67d53e1603fc5065 100644 (file)
@@ -1,8 +1,8 @@
-{ lib, pkgs, config, myconfig,  ... }:
+{ lib, pkgs, config,  ... }:
 let
   chloe = pkgs.callPackage ./builder.nix {
     inherit (pkgs.webapps) chloe;
-    config = myconfig.env.websites.chloe.production;
+    config = config.myEnv.websites.chloe.production;
     apacheUser = config.services.httpd.Prod.user;
     apacheGroup = config.services.httpd.Prod.group;
   };
@@ -12,26 +12,39 @@ in {
   options.myServices.websites.chloe.production.enable = lib.mkEnableOption "enable Chloe's website in production";
 
   config = lib.mkIf cfg.enable {
+    services.duplyBackup.profiles.chloe_prod.rootDir = chloe.app.varDir;
     secrets.keys = chloe.keys;
     services.webstats.sites = [ { name = "osteopathe-cc.fr"; } ];
 
-    services.myPhpfpm.serviceDependencies.chloe_prod = chloe.phpFpm.serviceDeps;
-    services.myPhpfpm.poolConfigs.chloe_prod = chloe.phpFpm.pool;
-    services.myPhpfpm.poolPhpConfigs.chloe_prod = ''
-      extension=${pkgs.php}/lib/php/extensions/mysqli.so
+    systemd.services.phpfpm-chloe_prod.after = lib.mkAfter chloe.phpFpm.serviceDeps;
+    systemd.services.phpfpm-chloe_prod.wants = chloe.phpFpm.serviceDeps;
+    services.phpfpm.pools.chloe_prod = {
+      user = config.services.httpd.Prod.user;
+      group = config.services.httpd.Prod.group;
+      settings = chloe.phpFpm.pool;
+      phpOptions = config.services.phpfpm.phpOptions + ''
+        extension=${pkgs.php}/lib/php/extensions/mysqli.so
       '';
+    };
     system.activationScripts.chloe_prod = chloe.activationScript;
-    system.extraSystemBuilderCmds = ''
-      mkdir -p $out/webapps
-      ln -s ${chloe.app.webRoot} $out/webapps/${chloe.apache.webappName}
-      '';
-    services.websites.production.modules = chloe.apache.modules;
-    services.websites.production.vhostConfs.chloe = {
+    myServices.websites.webappDirs."${chloe.apache.webappName}" = chloe.app.webRoot;
+    services.websites.env.production.modules = chloe.apache.modules;
+    services.websites.env.production.vhostConfs.chloe = {
       certName     = "chloe";
       certMainHost = "osteopathe-cc.fr";
       hosts        = ["osteopathe-cc.fr" "www.osteopathe-cc.fr" ];
       root         = chloe.apache.root;
-      extraConfig  = [ chloe.apache.vhostConf ];
+      extraConfig  = [
+        ''
+          RewriteEngine On
+          RewriteCond "%{HTTP_HOST}" "!^www\.osteopathe-cc\.fr$" [NC]
+          RewriteRule ^(.+)$ https://www.osteopathe-cc.fr$1 [R=302,L]
+          ''
+        (chloe.apache.vhostConf config.services.phpfpm.pools.chloe_prod.socket)
+      ];
     };
+    services.websites.env.production.watchPaths = [
+      "/var/secrets/webapps/${chloe.app.environment}-chloe"
+    ];
   };
 }