]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - modules/private/websites/tools/tools/yourls.nix
Move secrets to flakes
[perso/Immae/Config/Nix.git] / modules / private / websites / tools / tools / yourls.nix
index 466ceae1b857ee919e17a7f0c04e07b6d5e2c9ea..0f977f2842dac4b61a29f95d8baf6bbaba5379a5 100644 (file)
@@ -1,4 +1,4 @@
-{ env, yourls, yourls-plugins }:
+{ env, yourls, yourls-plugins, config }:
 rec {
   activationScript = {
     deps = [ "httpd" ];
@@ -40,19 +40,18 @@ rec {
       define( 'LDAPAUTH_USERCACHE_TYPE', 0);
     '';
   }];
-  webRoot = (yourls.override { yourls_config = "/var/secrets/webapps/tools-yourls"; }).withPlugins
-    (builtins.attrValues yourls-plugins);
+  webRoot = (yourls.override { yourls_config = config.secrets.fullPaths."webapps/tools-yourls"; }).withPlugins (p: [p.ldap]);
   apache = rec {
     user = "wwwrun";
     group = "wwwrun";
     modules = [ "proxy_fcgi" ];
     webappName = "tools_yourls";
     root = "/run/current-system/webapps/${webappName}";
-    vhostConf = ''
+    vhostConf = socket: ''
       Alias /url "${root}"
       <Directory "${root}">
         <FilesMatch "\.php$">
-          SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
+          SetHandler "proxy:unix:${socket}|fcgi://localhost"
         </FilesMatch>
 
         AllowOverride None
@@ -71,22 +70,19 @@ rec {
   phpFpm = rec {
     serviceDeps = [ "mysql.service" "openldap.service" ];
     basedir = builtins.concatStringsSep ":" (
-      [ webRoot "/var/secrets/webapps/tools-yourls" ]
+      [ webRoot config.secrets.fullPaths."webapps/tools-yourls" ]
       ++ webRoot.plugins);
-    socket = "/var/run/phpfpm/yourls.sock";
-    pool = ''
-      user = ${apache.user}
-      group = ${apache.group}
-      listen.owner = ${apache.user}
-      listen.group = ${apache.group}
-      pm = ondemand
-      pm.max_children = 60
-      pm.process_idle_timeout = 60
+    pool = {
+      "listen.owner" = apache.user;
+      "listen.group" = apache.group;
+      "pm" = "ondemand";
+      "pm.max_children" = "60";
+      "pm.process_idle_timeout" = "60";
 
-      ; Needed to avoid clashes in browser cookies (same domain)
-      php_value[session.name] = YourlsPHPSESSID
-      php_admin_value[open_basedir] = "${basedir}:/tmp:/var/lib/php/sessions/yourls"
-      php_admin_value[session.save_path] = "/var/lib/php/sessions/yourls"
-      '';
+      # Needed to avoid clashes in browser cookies (same domain)
+      "php_value[session.name]" = "YourlsPHPSESSID";
+      "php_admin_value[open_basedir]" = "${basedir}:/tmp:/var/lib/php/sessions/yourls";
+      "php_admin_value[session.save_path]" = "/var/lib/php/sessions/yourls";
+    };
   };
 }