]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - modules/websites/php-application.nix
Add config for CI
[perso/Immae/Config/Nix.git] / modules / websites / php-application.nix
index 8ad7a0dfe33e71ac3970242c5cbb3ff874259d1f..3a43a45e4bdd74e41dc59ca4322f8d3ac8297ee7 100644 (file)
@@ -1,4 +1,4 @@
-{ lib, config, ... }:
+{ lib, config, pkgs, ... }:
 with lib;
 let
   cfg = config.services.phpApplication;
@@ -44,10 +44,20 @@ in
             description = "Name of the socket to listen to. Defaults to app name if null";
           };
           phpPool = mkOption {
-            type = lines;
-            default = "";
+            type = attrsOf str;
+            default = {};
             description = "Pool configuration to append";
           };
+          phpEnv = mkOption {
+            type = attrsOf str;
+            default = {};
+            description = "Pool environment to append";
+          };
+          phpPackage = mkOption {
+            type = attrsOf str;
+            default = pkgs.php;
+            description = "Php package to use";
+          };
           phpOptions = mkOption {
             type = lines;
             default = "";
@@ -100,13 +110,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 = ''
@@ -135,21 +138,13 @@ in
     services.phpApplication.phpListenPaths = mkOption {
       type = attrsOf path;
       default = attrsets.mapAttrs' (name: icfg: attrsets.nameValuePair
-        name "/run/phpfpm/${if icfg.phpListen == null then name else icfg.phpListen}.sock"
+        name config.services.phpfpm.pools."${name}".socket
       ) cfg.apps;
       readOnly = true;
       description = ''
         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 = {
@@ -162,24 +157,20 @@ in
 
     services.phpfpm.pools = attrsets.mapAttrs' (name: icfg: attrsets.nameValuePair
       name {
-        listen = cfg.phpListenPaths."${name}";
-        extraConfig = ''
-          user = ${icfg.httpdUser}
-          group = ${icfg.httpdGroup}
-          listen.owner = ${icfg.httpdUser}
-          listen.group = ${icfg.httpdGroup}
-          ${optionalString (icfg.phpSession) ''
-            php_admin_value[session.save_path] = "${icfg.varDir}/phpSessions"''}
-          php_admin_value[open_basedir] = "${builtins.concatStringsSep ":" ([icfg.app icfg.varDir] ++ icfg.phpWatchFiles ++ icfg.phpOpenbasedir)}"
-          '' + icfg.phpPool;
+        user = icfg.httpdUser;
+        group = icfg.httpdUser;
+        settings = {
+          "listen.owner" = icfg.httpdUser;
+          "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 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;