]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - modules/private/websites/isabelle/aten_production.nix
Refactor websites
[perso/Immae/Config/Nix.git] / modules / private / websites / isabelle / aten_production.nix
index cf7e4a25456ba270ace16571dab3696c02a83a42..e34d65913e86d6b6410f0ec7c71df16b8dcf5782 100644 (file)
@@ -1,21 +1,24 @@
 { lib, pkgs, config,  ... }:
 let
   secrets = config.myEnv.websites.isabelle.aten_production;
-  app = pkgs.webapps.aten.override { environment = secrets.environment; };
+  app = pkgs.callPackage ./aten_app {
+    environment = secrets.environment;
+    varDir = "/var/lib/isabelle_aten_production";
+  };
   cfg = config.myServices.websites.isabelle.aten_production;
   pcfg = config.services.phpApplication;
 in {
   options.myServices.websites.isabelle.aten_production.enable = lib.mkEnableOption "enable Aten's website in production";
 
   config = lib.mkIf cfg.enable {
-    services.duplyBackup.profiles.aten_prod.rootDir = app.varDir;
+    services.duplyBackup.profiles.isabelle_aten_production.rootDir = app.varDir;
     services.webstats.sites = [ { name = "aten.pro"; } ];
-    services.phpApplication.apps.aten_prod = {
+    services.phpApplication.apps.isabelle_aten_production = {
       websiteEnv = "production";
       httpdUser = config.services.httpd.Prod.user;
       httpdGroup = config.services.httpd.Prod.group;
       httpdWatchFiles = [
-        config.secrets.fullPaths."webapps/${app.environment}-aten"
+        config.secrets.fullPaths."websites/isabelle/aten_production"
       ];
       inherit (app) webRoot varDir;
       inherit app;
@@ -37,7 +40,7 @@ in {
     };
 
     secrets.keys = [{
-      dest = "webapps/${app.environment}-aten";
+      dest = "websites/isabelle/aten_production";
       user = config.services.httpd.Prod.user;
       group = config.services.httpd.Prod.group;
       permissions = "0400";
@@ -52,18 +55,18 @@ in {
         SetEnv DATABASE_URL "${psql_url}"
         '';
     }];
-    services.websites.env.production.vhostConfs.aten_prod = {
-      certName     = "aten";
+    services.websites.env.production.vhostConfs.isabelle_aten_production = {
+      certName     = "isabelle";
       certMainHost = "aten.pro";
       hosts       = [ "aten.pro" "www.aten.pro" ];
-      root        = pcfg.webappDirs.aten_prod;
+      root        = pcfg.webappDirs.isabelle_aten_production;
       extraConfig = [
         ''
         <FilesMatch "\.php$">
-          SetHandler "proxy:unix:${pcfg.phpListenPaths.aten_prod}|fcgi://localhost"
+          SetHandler "proxy:unix:${pcfg.phpListenPaths.isabelle_aten_production}|fcgi://localhost"
         </FilesMatch>
 
-        Include ${config.secrets.fullPaths."webapps/${app.environment}-aten"}
+        Include ${config.secrets.fullPaths."websites/isabelle/aten_production"}
 
         Use Stats aten.pro
 
@@ -73,7 +76,7 @@ in {
           ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://aten.pro\"></html>"
         </Location>
 
-        <Directory ${pcfg.webappDirs.aten_prod}>
+        <Directory ${pcfg.webappDirs.isabelle_aten_production}>
           Options Indexes FollowSymLinks MultiViews Includes
           AllowOverride All
           Require all granted