nixos/phpfpm: add socket option to replace the listen option

wip/yesman
Aaron Andersen 5 years ago
parent 2b5f663015
commit 62b774a700
  1. 6
      nixos/modules/services/misc/zoneminder.nix
  2. 5
      nixos/modules/services/web-apps/icingaweb2/icingaweb2.nix
  3. 3
      nixos/modules/services/web-apps/limesurvey.nix
  4. 2
      nixos/modules/services/web-apps/mediawiki.nix
  5. 4
      nixos/modules/services/web-apps/nextcloud.nix
  6. 5
      nixos/modules/services/web-apps/restya-board.nix
  7. 2
      nixos/modules/services/web-apps/selfoss.nix
  8. 3
      nixos/modules/services/web-apps/tt-rss.nix
  9. 28
      nixos/modules/services/web-servers/phpfpm/default.nix

@ -2,6 +2,7 @@
let
cfg = config.services.zoneminder;
fpm = config.services.phpfpm.pools.zoneminder;
pkg = pkgs.zoneminder;
dirName = pkg.dirName;
@ -19,8 +20,6 @@ let
useCustomDir = cfg.storageDir != null;
socket = "/run/phpfpm/${dirName}.sock";
zms = "/cgi-bin/zms";
dirs = dirList: [ dirName ] ++ map (e: "${dirName}/${e}") dirList;
@ -274,7 +273,7 @@ in {
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_param HTTP_PROXY "";
fastcgi_pass unix:${socket};
fastcgi_pass unix:${fpm.socket};
}
}
'';
@ -284,7 +283,6 @@ in {
phpfpm = lib.mkIf useNginx {
pools.zoneminder = {
listen = socket;
phpOptions = ''
date.timezone = "${config.time.timeZone}"

@ -1,7 +1,7 @@
{ config, lib, pkgs, ... }: with lib; let
cfg = config.services.icingaweb2;
fpm = config.services.phpfpm.pools.${poolName};
poolName = "icingaweb2";
phpfpmSocketName = "/var/run/phpfpm/${poolName}.sock";
defaultConfig = {
global = {
@ -166,7 +166,6 @@ in {
config = mkIf cfg.enable {
services.phpfpm.pools = mkIf (cfg.pool == "${poolName}") {
"${poolName}" = {
listen = phpfpmSocketName;
extraConfig = ''
listen.owner = nginx
listen.group = nginx
@ -210,7 +209,7 @@ in {
include ${config.services.nginx.package}/conf/fastcgi.conf;
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:${phpfpmSocketName};
fastcgi_pass unix:${fpm.socket};
fastcgi_param SCRIPT_FILENAME ${pkgs.icingaweb2}/public/index.php;
'';
};

@ -203,7 +203,6 @@ in
};
services.phpfpm.pools.limesurvey = {
listen = "/run/phpfpm/limesurvey.sock";
extraConfig = ''
listen.owner = ${config.services.httpd.user};
listen.group = ${config.services.httpd.group};
@ -241,7 +240,7 @@ in
<Directory "${pkg}/share/limesurvey">
<FilesMatch "\.php$">
<If "-f %{REQUEST_FILENAME}">
SetHandler "proxy:unix:${fpm.listen}|fcgi://localhost/"
SetHandler "proxy:unix:${fpm.socket}|fcgi://localhost/"
</If>
</FilesMatch>

@ -403,7 +403,7 @@ in
<Directory "${pkg}/share/mediawiki">
<FilesMatch "\.php$">
<If "-f %{REQUEST_FILENAME}">
SetHandler "proxy:unix:${fpm.listen}|fcgi://localhost/"
SetHandler "proxy:unix:${fpm.socket}|fcgi://localhost/"
</If>
</FilesMatch>

@ -4,6 +4,7 @@ with lib;
let
cfg = config.services.nextcloud;
fpm = config.services.phpfpm.pools.nextcloud;
phpPackage = pkgs.php73;
phpPackages = pkgs.php73Packages;
@ -418,7 +419,6 @@ in {
in {
phpOptions = phpOptionsExtensions;
phpPackage = phpPackage;
listen = "/run/phpfpm/nextcloud";
extraConfig = ''
listen.owner = nginx
listen.group = nginx
@ -489,7 +489,7 @@ in {
fastcgi_param HTTPS ${if cfg.https then "on" else "off"};
fastcgi_param modHeadersAvailable true;
fastcgi_param front_controller_active true;
fastcgi_pass unix:/run/phpfpm/nextcloud;
fastcgi_pass unix:${fpm.socket};
fastcgi_intercept_errors on;
fastcgi_request_buffering off;
fastcgi_read_timeout 120s;

@ -9,11 +9,11 @@ with lib;
let
cfg = config.services.restya-board;
fpm = config.services.phpfpm.pools.${poolName};
runDir = "/run/restya-board";
poolName = "restya-board";
phpfpmSocketName = "/run/phpfpm/${poolName}.sock";
in
@ -180,7 +180,6 @@ in
services.phpfpm.pools = {
"${poolName}" = {
listen = phpfpmSocketName;
phpOptions = ''
date.timezone = "CET"
@ -241,7 +240,7 @@ in
tryFiles = "$uri =404";
extraConfig = ''
include ${pkgs.nginx}/conf/fastcgi_params;
fastcgi_pass unix:${phpfpmSocketName};
fastcgi_pass unix:${fpm.socket};
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PHP_VALUE "upload_max_filesize=9G \n post_max_size=9G \n max_execution_time=200 \n max_input_time=200 \n memory_limit=256M";

@ -4,7 +4,6 @@ let
cfg = config.services.selfoss;
poolName = "selfoss_pool";
phpfpmSocketName = "/run/phpfpm/${poolName}.sock";
dataDir = "/var/lib/selfoss";
@ -118,7 +117,6 @@ in
services.phpfpm.pools = mkIf (cfg.pool == "${poolName}") {
"${poolName}" = {
listen = phpfpmSocketName;
extraConfig = ''
listen.owner = nginx
listen.group = nginx

@ -521,7 +521,6 @@ let
services.phpfpm.pools = mkIf (cfg.pool == "${poolName}") {
"${poolName}" = {
listen = "/var/run/phpfpm/${poolName}.sock";
extraConfig = ''
listen.owner = nginx
listen.group = nginx
@ -552,7 +551,7 @@ let
locations."~ \.php$" = {
extraConfig = ''
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:${config.services.phpfpm.pools.${cfg.pool}.listen};
fastcgi_pass unix:${config.services.phpfpm.pools.${cfg.pool}.socket};
fastcgi_index index.php;
'';
};

@ -14,7 +14,7 @@ let
${cfg.extraConfig}
[${pool}]
listen = ${poolOpts.listen}
listen = ${poolOpts.socket}
${poolOpts.extraConfig}
'';
@ -29,11 +29,24 @@ let
cat $phpPackage/etc/php.ini $nixDefaultsPath $phpOptionsPath > $out
'';
poolOpts = { lib, ... }:
poolOpts = { lib, name, ... }:
let
poolOpts = cfg.pools."${name}";
in
{
options = {
socket = mkOption {
type = types.str;
readOnly = true;
description = ''
Path to the unix socket file on which to accept FastCGI requests.
<note><para>This option is read-only and managed by NixOS.</para></note>
'';
};
listen = mkOption {
type = types.str;
default = "";
example = "/path/to/unix/socket";
description = ''
The address on which to accept FastCGI requests.
@ -77,6 +90,10 @@ let
'';
};
};
config = {
socket = if poolOpts.listen == "" then "${stateDir}/${name}.sock" else poolOpts.listen;
};
};
in {
@ -121,7 +138,6 @@ in {
example = literalExample ''
{
mypool = {
listen = "/path/to/unix/socket";
phpPackage = pkgs.php;
extraConfig = '''
user = nobody
@ -144,6 +160,12 @@ in {
config = mkIf (cfg.pools != {}) {
warnings =
mapAttrsToList (pool: poolOpts: ''
Using config.services.phpfpm.pools.${pool}.listen is deprecated and will become unsupported. Please reference the read-only option config.services.phpfpm.pools.${pool}.socket to access the path of your socket.
'') (filterAttrs (pool: poolOpts: poolOpts.listen != "") cfg.pools)
;
systemd.slices.phpfpm = {
description = "PHP FastCGI Process manager pools slice";
};

Loading…
Cancel
Save