]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - modules/private/websites/florian/app.nix
Use attrs for secrets instead of lists
[perso/Immae/Config/Nix.git] / modules / private / websites / florian / app.nix
index c65c26f12d16a7836db13af5e8f15534b706a4ac..87e622a66a6a861b349549a52c1d4f945db49894 100644 (file)
@@ -2,15 +2,20 @@
 let
   adminer = pkgs.callPackage ../commons/adminer.nix { inherit config; };
   secrets = config.myEnv.websites.tellesflorian.integration;
-  app = pkgs.webapps.tellesflorian.override { environment = secrets.environment; };
+  app = pkgs.callPackage ./app {
+    composerEnv = pkgs.composerEnv.override { php = pkgs.php72; };
+    environment = secrets.environment;
+    varDir = "/var/lib/florian_app";
+    secretsPath = config.secrets.fullPaths."websites/florian/app";
+  };
   cfg = config.myServices.websites.florian.app;
   pcfg = config.services.phpApplication;
 in {
   options.myServices.websites.florian.app.enable = lib.mkEnableOption "enable Florian's app in integration";
 
   config = lib.mkIf cfg.enable {
-    services.duplyBackup.profiles.tellesflorian_dev.rootDir = app.varDir;
-    services.phpApplication.apps.florian_dev = {
+    services.duplyBackup.profiles.florian_app.rootDir = app.varDir;
+    services.phpApplication.apps.florian_app = {
       websiteEnv = "integration";
       httpdUser = config.services.httpd.Inte.user;
       httpdGroup = config.services.httpd.Inte.group;
@@ -33,25 +38,24 @@ in {
         "pm.process_idle_timeout" = "60";
       };
       phpEnv = {
-        SYMFONY_DEBUG_MODE = "yes";
+        SYMFONY_DEBUG_MODE = "\"yes\"";
       };
       phpWatchFiles = [
-        config.secrets.fullPaths."webapps/${app.environment}-tellesflorian"
+        config.secrets.fullPaths."websites/florian/app"
       ];
+      phpPackage = pkgs.php72;
     };
 
-    secrets.keys = [
-      {
-        dest = "webapps/${app.environment}-tellesflorian-passwords";
+    secrets.keys = {
+      "websites/florian/app_passwords" = {
         user = config.services.httpd.Inte.user;
         group = config.services.httpd.Inte.group;
         permissions = "0400";
         text = ''
           invite:${secrets.invite_passwords}
         '';
-      }
-      {
-        dest = "webapps/${app.environment}-tellesflorian";
+      };
+      "websites/florian/app" = {
         user = config.services.httpd.Inte.user;
         group = config.services.httpd.Inte.group;
         permissions = "0400";
@@ -69,19 +73,19 @@ in {
             mailer_password: null
             secret: ${secrets.secret}
         '';
-      }
-    ];
+      };
+    };
 
     services.websites.env.integration.modules = adminer.apache.modules;
-    services.websites.env.integration.vhostConfs.florian_dev = {
-      certName     = "integration";
+    services.websites.env.integration.vhostConfs.florian_app = {
+      certName    = "integration";
       addToCerts  = true;
       hosts       = [ "app.tellesflorian.com" ];
-      root        = pcfg.webappDirs.florian_dev;
+      root        = pcfg.webappDirs.florian_app;
       extraConfig = [
         ''
         <FilesMatch "\.php$">
-          SetHandler "proxy:unix:${pcfg.phpListenPaths.florian_dev}|fcgi://localhost"
+          SetHandler "proxy:unix:${pcfg.phpListenPaths.florian_app}|fcgi://localhost"
         </FilesMatch>
 
         <Location />
@@ -89,13 +93,13 @@ in {
           Use LDAPConnect
           Require ldap-group   cn=app.tellesflorian.com,cn=httpd,ou=services,dc=immae,dc=eu
 
-          AuthUserFile "${config.secrets.fullPaths."webapps/${app.environment}-tellesflorian-passwords"}"
+          AuthUserFile "${config.secrets.fullPaths."websites/florian/app_passwords"}"
           Require user "invite"
 
           ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://tellesflorian.com\"></html>"
         </Location>
 
-        <Directory ${pcfg.webappDirs.florian_dev}>
+        <Directory ${pcfg.webappDirs.florian_app}>
           Options Indexes FollowSymLinks MultiViews Includes
           AllowOverride None
           Require all granted