]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - modules/private/websites/tools/tools/default.nix
Migrate manual scripts from tools.immae.eu
[perso/Immae/Config/Nix.git] / modules / private / websites / tools / tools / default.nix
index 5e0d4460ae936c4f7ce33191cba52157716530ac..dbd65e63ffdb76fcaba36ea56a8368131c74d5b7 100644 (file)
@@ -38,6 +38,11 @@ let
   grocy = pkgs.callPackage ./grocy.nix {
     inherit (pkgs.webapps) grocy;
   };
+  webhooks = pkgs.callPackage ./webhooks.nix {
+    env = config.myEnv.tools.webhooks;
+  };
+
+  landing = pkgs.callPackage ./landing.nix {};
 
   cfg = config.myServices.websites.tools.tools;
   pcfg = config.services.phpfpm.pools;
@@ -53,7 +58,8 @@ in {
       ++ shaarli.keys
       ++ ttrss.keys
       ++ wallabag.keys
-      ++ yourls.keys;
+      ++ yourls.keys
+      ++ webhooks.keys;
 
     services.duplyBackup.profiles = {
       dokuwiki = dokuwiki.backups;
@@ -111,6 +117,17 @@ in {
           RedirectMatch 301 ^/roundcube(.*)$   https://mail.immae.eu/roundcube$1
           RedirectMatch 301 ^/jappix(.*)$      https://im.immae.fr/converse
 
+          Alias /landing ${landing}
+          <Directory "${landing}">
+            DirectoryIndex index.html
+            AllowOverride None
+            Require all granted
+
+            <FilesMatch "\.php$">
+              SetHandler "proxy:unix:${pcfg.tools.socket}|fcgi://localhost"
+            </FilesMatch>
+          </Directory>
+
           <Directory "/var/lib/ftp/tools.immae.eu">
             DirectoryIndex index.php index.htm index.html
             AllowOverride all
@@ -118,6 +135,11 @@ in {
             <FilesMatch "\.php$">
               SetHandler "proxy:unix:${pcfg.tools.socket}|fcgi://localhost"
             </FilesMatch>
+
+            RewriteEngine On
+            RewriteCond ${landing}%{REQUEST_URI} -f
+            RewriteRule ^(.*)$ /landing/$1 [L]
+            RewriteRule ^$ /landing/ [L]
           </Directory>
           ''
         (adminer.apache.vhostConf pcfg.adminer.socket)
@@ -131,6 +153,32 @@ in {
         (ldap.apache.vhostConf pcfg.ldap.socket)
         (kanboard.apache.vhostConf pcfg.kanboard.socket)
         (grocy.apache.vhostConf pcfg.grocy.socket)
+        ''
+          Alias /paste /var/lib/fiche
+          <Directory "/var/lib/fiche">
+            DirectoryIndex index.txt index.html
+            AllowOverride None
+            Require all granted
+            Options -Indexes
+          </Directory>
+
+          Alias /BIP39 /var/lib/buildbot/outputs/bip39
+          <Directory "/var/lib/buildbot/outputs/bip39">
+            DirectoryIndex index.html
+            AllowOverride None
+            Require all granted
+          </Directory>
+
+          Alias /webhooks ${config.secrets.location}/webapps/webhooks
+          <Directory "${config.secrets.location}/webapps/webhooks">
+            Options -Indexes
+            Require all granted
+            AllowOverride None
+            <FilesMatch "\.php$">
+              SetHandler "proxy:unix:${pcfg.tools.socket}|fcgi://localhost"
+            </FilesMatch>
+          </Directory>
+        ''
       ];
     };
 
@@ -240,7 +288,13 @@ in {
 
           # Needed to avoid clashes in browser cookies (same domain)
           "php_value[session.name]" = "ToolsPHPSESSID";
-          "php_admin_value[open_basedir]" = "/run/wrappers/bin/sendmail:/var/lib/ftp/tools.immae.eu:/tmp";
+          "php_admin_value[open_basedir]" = builtins.concatStringsSep ":" [
+            "/run/wrappers/bin/sendmail" "/var/lib/ftp/tools.immae.eu"
+            landing "/tmp" "${config.secrets.location}/webapps/webhooks"
+          ];
+        };
+        phpEnv = {
+          CONTACT_EMAIL = config.myEnv.tools.contact;
         };
       };
       devtools = {
@@ -299,6 +353,7 @@ in {
         user = "wwwrun";
         group = "wwwrun";
         settings = ldap.phpFpm.pool;
+        phpPackage = pkgs.php72;
       };
       kanboard = {
         user = "wwwrun";
@@ -325,7 +380,7 @@ in {
       ldap = ldap.activationScript;
     };
 
-    myServices.websites.webappDirs = {
+    services.websites.webappDirs = {
       _adminer = adminer.webRoot;
       "${dokuwiki.apache.webappName}" = dokuwiki.webRoot;
       "${ldap.apache.webappName}" = "${ldap.webRoot}/htdocs";
@@ -345,6 +400,13 @@ in {
       restart = true;
       paths = [ "/var/secrets/webapps/tools-wallabag" ];
     };
+
+    services.fiche = {
+      enable = true;
+      port = config.myEnv.ports.fiche;
+      domain = "tools.immae.eu/paste";
+      https = true;
+    };
   };
 }