]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - modules/websites/php-application.nix
Migrate php sessions to redis
[perso/Immae/Config/Nix.git] / modules / websites / php-application.nix
index 20e2a5dde77311103aa2ab71c4ff53a4f54c3d1e..caecb6f85f748d9b9fa5a159af10ce45381cc415 100644 (file)
@@ -1,4 +1,4 @@
-{ lib, config, ... }:
+{ lib, config, pkgs, ... }:
 with lib;
 let
   cfg = config.services.phpApplication;
@@ -33,11 +33,6 @@ in
               Mode to apply to the vardir
               '';
           };
-          phpSession = mkOption {
-            type = bool;
-            default = true;
-            description = "Handle phpsession files separately in vardir";
-          };
           phpListen = mkOption {
             type = nullOr str;
             default = null;
@@ -53,6 +48,11 @@ in
             default = {};
             description = "Pool environment to append";
           };
+          phpPackage = mkOption {
+            type = attrsOf str;
+            default = pkgs.php;
+            description = "Php package to use";
+          };
           phpOptions = mkOption {
             type = lines;
             default = "";
@@ -105,19 +105,6 @@ in
               Path to application root
               '';
           };
-          webappName = mkOption {
-            type = nullOr str;
-            default = null;
-            description = ''
-              Alias name for the app, to be used in services.websites.webappDirs
-              '';
-          };
-          webRoot = mkOption {
-            type = nullOr path;
-            description = ''
-              Path to the web root path of the application. May differ from the application itself (usually a subdirectory)
-              '';
-          };
           preStartActions = mkOption {
             type = listOf str;
             default = [];
@@ -147,14 +134,6 @@ in
         Full paths to listen for php
         '';
     };
-    services.phpApplication.webappDirs = mkOption {
-      type = attrsOf path;
-      default = attrsets.filterAttrs (n: v: builtins.hasAttr n cfg.apps) config.services.websites.webappDirsPaths;
-      readOnly = true;
-      description = ''
-        Stable name webapp dirs for httpd
-        '';
-    };
   };
 
   config = {
@@ -165,6 +144,7 @@ in
       }
     ) cfgByEnv;
 
+    services.phpfpm.phpPackage = pkgs.php74;
     services.phpfpm.pools = attrsets.mapAttrs' (name: icfg: attrsets.nameValuePair
       name {
         user = icfg.httpdUser;
@@ -174,17 +154,12 @@ in
           "listen.group" = icfg.httpdGroup;
           "php_admin_value[open_basedir]" = builtins.concatStringsSep ":" ([icfg.app icfg.varDir] ++ icfg.phpWatchFiles ++ icfg.phpOpenbasedir);
         }
-        // optionalAttrs (icfg.phpSession) { "php_admin_value[session.save_path]" = "${icfg.varDir}/phpSessions"; }
         // icfg.phpPool;
         phpOptions = config.services.phpfpm.phpOptions + icfg.phpOptions;
-        inherit (icfg) phpEnv;
+        inherit (icfg) phpEnv phpPackage;
       }
     ) cfg.apps;
 
-    services.websites.webappDirs = attrsets.mapAttrs' (name: icfg: attrsets.nameValuePair
-      (if icfg.webappName == null then name else icfg.webappName) icfg.webRoot
-    ) (attrsets.filterAttrs (n: v: !isNull v.webRoot) cfg.apps);
-
     services.filesWatcher = attrsets.mapAttrs' (name: icfg: attrsets.nameValuePair
       "phpfpm-${name}" {
         restart = true;
@@ -227,8 +202,6 @@ in
         deps = [];
         text = optionalString (!isNull icfg.varDir) ''
           install -m ${icfg.mode} -o ${icfg.httpdUser} -g ${icfg.httpdGroup} -d ${icfg.varDir}
-          '' + optionalString (icfg.phpSession) ''
-          install -m 0700 -o ${icfg.httpdUser} -g ${icfg.httpdGroup} -d ${icfg.varDir}/phpSessions
           '' + builtins.concatStringsSep "\n" (attrsets.mapAttrsToList (n: v: ''
             install -m ${v} -o ${icfg.httpdUser} -g ${icfg.httpdGroup} -d ${icfg.varDir}/${n}
             '') icfg.varDirPaths);