]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - modules/private/websites/ludivine/production.nix
Refactor websites
[perso/Immae/Config/Nix.git] / modules / private / websites / ludivine / production.nix
similarity index 71%
rename from modules/private/websites/ludivinecassal/production.nix
rename to modules/private/websites/ludivine/production.nix
index 5761be7af22d352b08d536f502854d931f5997a6..47450c54c249f8a90ab2421dc272260a10235c6f 100644 (file)
@@ -1,16 +1,20 @@
 { lib, pkgs, config,  ... }:
 let
-  secrets = config.myEnv.websites.ludivinecassal.production;
-  app = pkgs.webapps.ludivinecassal.override { environment = secrets.environment; };
+  secrets = config.myEnv.websites.ludivine.production;
+  app = pkgs.callPackage ./app {
+    environment = secrets.environment;
+    varDir = "/var/lib/ludivine_production";
+    secretsPath = config.secrets.fullPaths."websites/ludivine/production";
+  };
   pcfg = config.services.phpApplication;
-  cfg = config.myServices.websites.ludivinecassal.production;
+  cfg = config.myServices.websites.ludivine.production;
 in {
-  options.myServices.websites.ludivinecassal.production.enable = lib.mkEnableOption "enable Ludivine's website in production";
+  options.myServices.websites.ludivine.production.enable = lib.mkEnableOption "enable Ludivine's website in production";
 
   config = lib.mkIf cfg.enable {
-    services.duplyBackup.profiles.ludivinecassal_prod.rootDir = app.varDir;
+    services.duplyBackup.profiles.ludivine_production.rootDir = app.varDir;
     services.webstats.sites = [ { name = "ludivinecassal.com"; } ];
-    services.phpApplication.apps.ludivinecassal_prod = {
+    services.phpApplication.apps.ludivine_production = {
       websiteEnv = "production";
       httpdUser = config.services.httpd.Prod.user;
       httpdGroup = config.services.httpd.Prod.group;
@@ -35,13 +39,20 @@ in {
         "pm.max_spare_servers" = "3";
       };
       phpWatchFiles = [
-        config.secrets.fullPaths."webapps/${app.environment}-ludivinecassal"
+        config.secrets.fullPaths."websites/ludivine/production"
       ];
+      phpEnv = {
+        PATH = lib.makeBinPath [
+          # below ones don't need to be in the PATH but they’re used in
+          # secrets
+          pkgs.imagemagick pkgs.sass pkgs.ruby
+        ];
+      };
     };
 
     secrets.keys = [
       {
-        dest = "webapps/${app.environment}-ludivinecassal";
+        dest = "websites/ludivine/production";
         user = config.services.httpd.Prod.user;
         group = config.services.httpd.Prod.group;
         permissions = "0400";
@@ -78,11 +89,11 @@ in {
       }
     ];
 
-    services.websites.env.production.vhostConfs.ludivinecassal_prod = {
-      certName     = "ludivinecassal";
+    services.websites.env.production.vhostConfs.ludivine_production = {
+      certName     = "ludivine";
       certMainHost = "ludivinecassal.com";
       hosts        = ["ludivinecassal.com" "www.ludivinecassal.com" ];
-      root         = pcfg.webappDirs.ludivinecassal_prod;
+      root         = pcfg.webappDirs.ludivine_production;
       extraConfig  = [
         ''
         RewriteEngine on
@@ -90,12 +101,12 @@ in {
         RewriteRule ^(.+)$ https://ludivinecassal.com$1 [R=302,L]
 
         <FilesMatch "\.php$">
-          SetHandler "proxy:unix:${pcfg.phpListenPaths.ludivinecassal_prod}|fcgi://localhost"
+          SetHandler "proxy:unix:${pcfg.phpListenPaths.ludivine_production}|fcgi://localhost"
         </FilesMatch>
 
         Use Stats ludivinecassal.com
 
-        <Directory ${pcfg.webappDirs.ludivinecassal_prod}>
+        <Directory ${pcfg.webappDirs.ludivine_production}>
           Options Indexes FollowSymLinks MultiViews Includes
           AllowOverride All
           Require all granted