nixos/phpfpm: deprecate extraConfig options in favor of settings options
This commit is contained in:
parent
d2db3a338c
commit
400c6aac71
12 changed files with 254 additions and 212 deletions
|
@ -4,6 +4,7 @@ with lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.services.roundcube;
|
cfg = config.services.roundcube;
|
||||||
|
fpm = config.services.phpfpm.pools.roundcube;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.services.roundcube = {
|
options.services.roundcube = {
|
||||||
|
@ -105,7 +106,7 @@ in
|
||||||
extraConfig = ''
|
extraConfig = ''
|
||||||
location ~* \.php$ {
|
location ~* \.php$ {
|
||||||
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
||||||
fastcgi_pass unix:/run/phpfpm/roundcube;
|
fastcgi_pass unix:${fpm.socket};
|
||||||
include ${pkgs.nginx}/conf/fastcgi_params;
|
include ${pkgs.nginx}/conf/fastcgi_params;
|
||||||
include ${pkgs.nginx}/conf/fastcgi.conf;
|
include ${pkgs.nginx}/conf/fastcgi.conf;
|
||||||
}
|
}
|
||||||
|
@ -120,24 +121,25 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
services.phpfpm.pools.roundcube = {
|
services.phpfpm.pools.roundcube = {
|
||||||
listen = "/run/phpfpm/roundcube";
|
user = "nginx";
|
||||||
extraConfig = ''
|
phpOptions = ''
|
||||||
listen.owner = nginx
|
error_log = 'stderr'
|
||||||
listen.group = nginx
|
log_errors = on
|
||||||
listen.mode = 0660
|
post_max_size = 25M
|
||||||
user = nginx
|
upload_max_filesize = 25M
|
||||||
pm = dynamic
|
|
||||||
pm.max_children = 75
|
|
||||||
pm.start_servers = 2
|
|
||||||
pm.min_spare_servers = 1
|
|
||||||
pm.max_spare_servers = 20
|
|
||||||
pm.max_requests = 500
|
|
||||||
php_admin_value[error_log] = 'stderr'
|
|
||||||
php_admin_flag[log_errors] = on
|
|
||||||
php_admin_value[post_max_size] = 25M
|
|
||||||
php_admin_value[upload_max_filesize] = 25M
|
|
||||||
catch_workers_output = yes
|
|
||||||
'';
|
'';
|
||||||
|
settings = mapAttrs (name: mkDefault) {
|
||||||
|
"listen.owner" = "nginx";
|
||||||
|
"listen.group" = "nginx";
|
||||||
|
"listen.mode" = "0660";
|
||||||
|
"pm" = "dynamic";
|
||||||
|
"pm.max_children" = 75;
|
||||||
|
"pm.start_servers" = 2;
|
||||||
|
"pm.min_spare_servers" = 1;
|
||||||
|
"pm.max_spare_servers" = 20;
|
||||||
|
"pm.max_requests" = 500;
|
||||||
|
"catch_workers_output" = true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
systemd.services.phpfpm-roundcube.after = [ "roundcube-setup.service" ];
|
systemd.services.phpfpm-roundcube.after = [ "roundcube-setup.service" ];
|
||||||
|
|
||||||
|
|
|
@ -283,29 +283,27 @@ in {
|
||||||
|
|
||||||
phpfpm = lib.mkIf useNginx {
|
phpfpm = lib.mkIf useNginx {
|
||||||
pools.zoneminder = {
|
pools.zoneminder = {
|
||||||
|
inherit user group;
|
||||||
phpOptions = ''
|
phpOptions = ''
|
||||||
date.timezone = "${config.time.timeZone}"
|
date.timezone = "${config.time.timeZone}"
|
||||||
|
|
||||||
${lib.concatStringsSep "\n" (map (e:
|
${lib.concatStringsSep "\n" (map (e:
|
||||||
"extension=${e.pkg}/lib/php/extensions/${e.name}.so") phpExtensions)}
|
"extension=${e.pkg}/lib/php/extensions/${e.name}.so") phpExtensions)}
|
||||||
'';
|
'';
|
||||||
extraConfig = ''
|
settings = lib.mapAttrs (name: lib.mkDefault) {
|
||||||
user = ${user}
|
"listen.owner" = user;
|
||||||
group = ${group}
|
"listen.group" = group;
|
||||||
|
"listen.mode" = "0660";
|
||||||
|
|
||||||
listen.owner = ${user}
|
"pm" = "dynamic";
|
||||||
listen.group = ${group}
|
"pm.start_servers" = 1;
|
||||||
listen.mode = 0660
|
"pm.min_spare_servers" = 1;
|
||||||
|
"pm.max_spare_servers" = 2;
|
||||||
pm = dynamic
|
"pm.max_requests" = 500;
|
||||||
pm.start_servers = 1
|
"pm.max_children" = 5;
|
||||||
pm.min_spare_servers = 1
|
"pm.status_path" = "/$pool-status";
|
||||||
pm.max_spare_servers = 2
|
"ping.path" = "/$pool-ping";
|
||||||
pm.max_requests = 500
|
};
|
||||||
pm.max_children = 5
|
|
||||||
pm.status_path = /$pool-status
|
|
||||||
ping.path = /$pool-ping
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -166,26 +166,24 @@ in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
services.phpfpm.pools = mkIf (cfg.pool == "${poolName}") {
|
services.phpfpm.pools = mkIf (cfg.pool == "${poolName}") {
|
||||||
"${poolName}" = {
|
"${poolName}" = {
|
||||||
extraConfig = ''
|
user = "icingaweb2";
|
||||||
listen.owner = nginx
|
phpOptions = ''
|
||||||
listen.group = nginx
|
extension = ${pkgs.phpPackages.imagick}/lib/php/extensions/imagick.so
|
||||||
listen.mode = 0600
|
date.timezone = "${cfg.timezone}"
|
||||||
user = icingaweb2
|
|
||||||
pm = dynamic
|
|
||||||
pm.max_children = 75
|
|
||||||
pm.start_servers = 2
|
|
||||||
pm.min_spare_servers = 2
|
|
||||||
pm.max_spare_servers = 10
|
|
||||||
'';
|
'';
|
||||||
|
settings = mapAttrs (name: mkDefault) {
|
||||||
|
"listen.owner" = "nginx";
|
||||||
|
"listen.group" = "nginx";
|
||||||
|
"listen.mode" = "0600";
|
||||||
|
"pm" = "dynamic";
|
||||||
|
"pm.max_children" = 75;
|
||||||
|
"pm.start_servers" = 2;
|
||||||
|
"pm.min_spare_servers" = 2;
|
||||||
|
"pm.max_spare_servers" = 10;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
services.phpfpm.phpOptions = mkIf (cfg.pool == "${poolName}")
|
|
||||||
''
|
|
||||||
extension = ${pkgs.phpPackages.imagick}/lib/php/extensions/imagick.so
|
|
||||||
date.timezone = "${cfg.timezone}"
|
|
||||||
'';
|
|
||||||
|
|
||||||
systemd.services."phpfpm-${poolName}".serviceConfig.ReadWritePaths = [ "/etc/icingaweb2" ];
|
systemd.services."phpfpm-${poolName}".serviceConfig.ReadWritePaths = [ "/etc/icingaweb2" ];
|
||||||
|
|
||||||
services.nginx = {
|
services.nginx = {
|
||||||
|
|
|
@ -120,15 +120,15 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
poolConfig = mkOption {
|
poolConfig = mkOption {
|
||||||
type = types.lines;
|
type = with types; attrsOf (oneOf [ str int bool ]);
|
||||||
default = ''
|
default = {
|
||||||
pm = dynamic
|
"pm" = "dynamic";
|
||||||
pm.max_children = 32
|
"pm.max_children" = 32;
|
||||||
pm.start_servers = 2
|
"pm.start_servers" = 2;
|
||||||
pm.min_spare_servers = 2
|
"pm.min_spare_servers" = 2;
|
||||||
pm.max_spare_servers = 4
|
"pm.max_spare_servers" = 4;
|
||||||
pm.max_requests = 500
|
"pm.max_requests" = 500;
|
||||||
'';
|
};
|
||||||
description = ''
|
description = ''
|
||||||
Options for the LimeSurvey PHP pool. See the documentation on <literal>php-fpm.conf</literal>
|
Options for the LimeSurvey PHP pool. See the documentation on <literal>php-fpm.conf</literal>
|
||||||
for details on configuration directives.
|
for details on configuration directives.
|
||||||
|
@ -204,14 +204,11 @@ in
|
||||||
|
|
||||||
services.phpfpm.pools.limesurvey = {
|
services.phpfpm.pools.limesurvey = {
|
||||||
inherit user group;
|
inherit user group;
|
||||||
extraConfig = ''
|
phpEnv.LIMESURVEY_CONFIG = "${limesurveyConfig}";
|
||||||
listen.owner = ${config.services.httpd.user};
|
settings = {
|
||||||
listen.group = ${config.services.httpd.group};
|
"listen.owner" = config.services.httpd.user;
|
||||||
|
"listen.group" = config.services.httpd.group;
|
||||||
env[LIMESURVEY_CONFIG] = ${limesurveyConfig}
|
} // cfg.poolConfig;
|
||||||
|
|
||||||
${cfg.poolConfig}
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
|
|
||||||
services.httpd = {
|
services.httpd = {
|
||||||
|
|
|
@ -312,17 +312,17 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
poolConfig = mkOption {
|
poolConfig = mkOption {
|
||||||
type = types.lines;
|
type = with types; attrsOf (oneOf [ str int bool ]);
|
||||||
default = ''
|
default = {
|
||||||
pm = dynamic
|
"pm" = "dynamic";
|
||||||
pm.max_children = 32
|
"pm.max_children" = 32;
|
||||||
pm.start_servers = 2
|
"pm.start_servers" = 2;
|
||||||
pm.min_spare_servers = 2
|
"pm.min_spare_servers" = 2;
|
||||||
pm.max_spare_servers = 4
|
"pm.max_spare_servers" = 4;
|
||||||
pm.max_requests = 500
|
"pm.max_requests" = 500;
|
||||||
'';
|
};
|
||||||
description = ''
|
description = ''
|
||||||
Options for MediaWiki's PHP pool. See the documentation on <literal>php-fpm.conf</literal>
|
Options for the MediaWiki PHP pool. See the documentation on <literal>php-fpm.conf</literal>
|
||||||
for details on configuration directives.
|
for details on configuration directives.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
@ -379,17 +379,12 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
services.phpfpm.pools.mediawiki = {
|
services.phpfpm.pools.mediawiki = {
|
||||||
listen = "/run/phpfpm/mediawiki.sock";
|
inherit user group;
|
||||||
extraConfig = ''
|
phpEnv.MEDIAWIKI_CONFIG = "${mediawikiConfig}";
|
||||||
listen.owner = ${config.services.httpd.user}
|
settings = {
|
||||||
listen.group = ${config.services.httpd.group}
|
"listen.owner" = config.services.httpd.user;
|
||||||
user = ${user}
|
"listen.group" = config.services.httpd.group;
|
||||||
group = ${group}
|
} // cfg.poolConfig;
|
||||||
|
|
||||||
env[MEDIAWIKI_CONFIG] = ${mediawikiConfig}
|
|
||||||
|
|
||||||
${cfg.poolConfig}
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
|
|
||||||
services.httpd = {
|
services.httpd = {
|
||||||
|
|
|
@ -411,24 +411,20 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
services.phpfpm = {
|
services.phpfpm = {
|
||||||
pools.nextcloud = let
|
pools.nextcloud = {
|
||||||
phpAdminValues = (toKeyValue
|
user = "nextcloud";
|
||||||
(foldr (a: b: a // b) {}
|
group = "nginx";
|
||||||
(mapAttrsToList (k: v: { "php_admin_value[${k}]" = v; })
|
phpOptions = phpOptionsExtensions + phpOptionsStr;
|
||||||
phpOptions)));
|
|
||||||
in {
|
|
||||||
phpOptions = phpOptionsExtensions;
|
|
||||||
phpPackage = phpPackage;
|
phpPackage = phpPackage;
|
||||||
extraConfig = ''
|
phpEnv = {
|
||||||
listen.owner = nginx
|
NEXTCLOUD_CONFIG_DIR = "${cfg.home}/config";
|
||||||
listen.group = nginx
|
PATH = "/run/wrappers/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin:/usr/bin:/bin";
|
||||||
user = nextcloud
|
};
|
||||||
group = nginx
|
settings = mapAttrs (name: mkDefault) {
|
||||||
${cfg.poolConfig}
|
"listen.owner" = "nginx";
|
||||||
env[NEXTCLOUD_CONFIG_DIR] = ${cfg.home}/config
|
"listen.group" = "nginx";
|
||||||
env[PATH] = /run/wrappers/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin:/usr/bin:/bin
|
};
|
||||||
${phpAdminValues}
|
extraConfig = cfg.poolConfig;
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -180,6 +180,7 @@ in
|
||||||
|
|
||||||
services.phpfpm.pools = {
|
services.phpfpm.pools = {
|
||||||
"${poolName}" = {
|
"${poolName}" = {
|
||||||
|
inherit (cfg) user group;
|
||||||
phpOptions = ''
|
phpOptions = ''
|
||||||
date.timezone = "CET"
|
date.timezone = "CET"
|
||||||
|
|
||||||
|
@ -190,20 +191,18 @@ in
|
||||||
auth_password = ${cfg.email.password}
|
auth_password = ${cfg.email.password}
|
||||||
''}
|
''}
|
||||||
'';
|
'';
|
||||||
extraConfig = ''
|
settings = mapAttrs (name: mkDefault) {
|
||||||
listen.owner = nginx
|
"listen.owner" = "nginx";
|
||||||
listen.group = nginx
|
"listen.group" = "nginx";
|
||||||
listen.mode = 0600
|
"listen.mode" = "0600";
|
||||||
user = ${cfg.user}
|
"pm" = "dynamic";
|
||||||
group = ${cfg.group}
|
"pm.max_children" = 75;
|
||||||
pm = dynamic
|
"pm.start_servers" = 10;
|
||||||
pm.max_children = 75
|
"pm.min_spare_servers" = 5;
|
||||||
pm.start_servers = 10
|
"pm.max_spare_servers" = 20;
|
||||||
pm.min_spare_servers = 5
|
"pm.max_requests" = 500;
|
||||||
pm.max_spare_servers = 20
|
"catch_workers_output" = 1;
|
||||||
pm.max_requests = 500
|
};
|
||||||
catch_workers_output = 1
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -117,19 +117,19 @@ in
|
||||||
|
|
||||||
services.phpfpm.pools = mkIf (cfg.pool == "${poolName}") {
|
services.phpfpm.pools = mkIf (cfg.pool == "${poolName}") {
|
||||||
"${poolName}" = {
|
"${poolName}" = {
|
||||||
extraConfig = ''
|
user = "nginx";
|
||||||
listen.owner = nginx
|
settings = mapAttrs (name: mkDefault) {
|
||||||
listen.group = nginx
|
"listen.owner" = "nginx";
|
||||||
listen.mode = 0600
|
"listen.group" = "nginx";
|
||||||
user = nginx
|
"listen.mode" = "0600";
|
||||||
pm = dynamic
|
"pm" = "dynamic";
|
||||||
pm.max_children = 75
|
"pm.max_children" = 75;
|
||||||
pm.start_servers = 10
|
"pm.start_servers" = 10;
|
||||||
pm.min_spare_servers = 5
|
"pm.min_spare_servers" = 5;
|
||||||
pm.max_spare_servers = 20
|
"pm.max_spare_servers" = 20;
|
||||||
pm.max_requests = 500
|
"pm.max_requests" = 500;
|
||||||
catch_workers_output = 1
|
"catch_workers_output" = 1;
|
||||||
'';
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -521,19 +521,19 @@ let
|
||||||
|
|
||||||
services.phpfpm.pools = mkIf (cfg.pool == "${poolName}") {
|
services.phpfpm.pools = mkIf (cfg.pool == "${poolName}") {
|
||||||
"${poolName}" = {
|
"${poolName}" = {
|
||||||
extraConfig = ''
|
inherit (cfg) user;
|
||||||
listen.owner = nginx
|
settings = mapAttrs (name: mkDefault) {
|
||||||
listen.group = nginx
|
"listen.owner" = "nginx";
|
||||||
listen.mode = 0600
|
"listen.group" = "nginx";
|
||||||
user = ${cfg.user}
|
"listen.mode" = "0600";
|
||||||
pm = dynamic
|
"pm" = "dynamic";
|
||||||
pm.max_children = 75
|
"pm.max_children" = 75;
|
||||||
pm.start_servers = 10
|
"pm.start_servers" = 10;
|
||||||
pm.min_spare_servers = 5
|
"pm.min_spare_servers" = 5;
|
||||||
pm.max_spare_servers = 20
|
"pm.max_spare_servers" = 20;
|
||||||
pm.max_requests = 500
|
"pm.max_requests" = 500;
|
||||||
catch_workers_output = 1
|
"catch_workers_output" = 1;
|
||||||
'';
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -216,15 +216,15 @@ let
|
||||||
};
|
};
|
||||||
|
|
||||||
poolConfig = mkOption {
|
poolConfig = mkOption {
|
||||||
type = types.lines;
|
type = with types; attrsOf (oneOf [ str int bool ]);
|
||||||
default = ''
|
default = {
|
||||||
pm = dynamic
|
"pm" = "dynamic";
|
||||||
pm.max_children = 32
|
"pm.max_children" = 32;
|
||||||
pm.start_servers = 2
|
"pm.start_servers" = 2;
|
||||||
pm.min_spare_servers = 2
|
"pm.min_spare_servers" = 2;
|
||||||
pm.max_spare_servers = 4
|
"pm.max_spare_servers" = 4;
|
||||||
pm.max_requests = 500
|
"pm.max_requests" = 500;
|
||||||
'';
|
};
|
||||||
description = ''
|
description = ''
|
||||||
Options for the WordPress PHP pool. See the documentation on <literal>php-fpm.conf</literal>
|
Options for the WordPress PHP pool. See the documentation on <literal>php-fpm.conf</literal>
|
||||||
for details on configuration directives.
|
for details on configuration directives.
|
||||||
|
@ -280,15 +280,11 @@ in
|
||||||
|
|
||||||
services.phpfpm.pools = mapAttrs' (hostName: cfg: (
|
services.phpfpm.pools = mapAttrs' (hostName: cfg: (
|
||||||
nameValuePair "wordpress-${hostName}" {
|
nameValuePair "wordpress-${hostName}" {
|
||||||
listen = "/run/phpfpm/wordpress-${hostName}.sock";
|
inherit user group;
|
||||||
extraConfig = ''
|
settings = {
|
||||||
listen.owner = ${config.services.httpd.user}
|
"listen.owner" = config.services.httpd.user;
|
||||||
listen.group = ${config.services.httpd.group}
|
"listen.group" = config.services.httpd.group;
|
||||||
user = ${user}
|
} // cfg.poolConfig;
|
||||||
group = ${group}
|
|
||||||
|
|
||||||
${cfg.poolConfig}
|
|
||||||
'';
|
|
||||||
}
|
}
|
||||||
)) eachSite;
|
)) eachSite;
|
||||||
|
|
||||||
|
@ -303,7 +299,7 @@ in
|
||||||
<Directory "${pkg hostName cfg}/share/wordpress">
|
<Directory "${pkg hostName cfg}/share/wordpress">
|
||||||
<FilesMatch "\.php$">
|
<FilesMatch "\.php$">
|
||||||
<If "-f %{REQUEST_FILENAME}">
|
<If "-f %{REQUEST_FILENAME}">
|
||||||
SetHandler "proxy:unix:/run/phpfpm/wordpress-${hostName}.sock|fcgi://localhost/"
|
SetHandler "proxy:unix:${config.services.phpfpm.pools."wordpress-${hostName}".socket}|fcgi://localhost/"
|
||||||
</If>
|
</If>
|
||||||
</FilesMatch>
|
</FilesMatch>
|
||||||
|
|
||||||
|
|
|
@ -133,15 +133,15 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
poolConfig = mkOption {
|
poolConfig = mkOption {
|
||||||
type = types.lines;
|
type = with types; attrsOf (oneOf [ str int bool ]);
|
||||||
default = ''
|
default = {
|
||||||
pm = dynamic
|
"pm" = "dynamic";
|
||||||
pm.max_children = 32
|
"pm.max_children" = 32;
|
||||||
pm.start_servers = 2
|
"pm.start_servers" = 2;
|
||||||
pm.min_spare_servers = 2
|
"pm.min_spare_servers" = 2;
|
||||||
pm.max_spare_servers = 4
|
"pm.max_spare_servers" = 4;
|
||||||
pm.max_requests = 500
|
"pm.max_requests" = 500;
|
||||||
'';
|
};
|
||||||
description = ''
|
description = ''
|
||||||
Options for the Zabbix PHP pool. See the documentation on <literal>php-fpm.conf</literal> for details on configuration directives.
|
Options for the Zabbix PHP pool. See the documentation on <literal>php-fpm.conf</literal> for details on configuration directives.
|
||||||
'';
|
'';
|
||||||
|
@ -160,6 +160,8 @@ in
|
||||||
];
|
];
|
||||||
|
|
||||||
services.phpfpm.pools.zabbix = {
|
services.phpfpm.pools.zabbix = {
|
||||||
|
inherit user;
|
||||||
|
group = config.services.httpd.group;
|
||||||
phpOptions = ''
|
phpOptions = ''
|
||||||
# https://www.zabbix.com/documentation/current/manual/installation/install
|
# https://www.zabbix.com/documentation/current/manual/installation/install
|
||||||
memory_limit = 128M
|
memory_limit = 128M
|
||||||
|
@ -177,15 +179,11 @@ in
|
||||||
'' + optionalString (cfg.database.type == "oracle") ''
|
'' + optionalString (cfg.database.type == "oracle") ''
|
||||||
extension=${pkgs.phpPackages.oci8}/lib/php/extensions/oci8.so
|
extension=${pkgs.phpPackages.oci8}/lib/php/extensions/oci8.so
|
||||||
'';
|
'';
|
||||||
listen = "/run/phpfpm/zabbix.sock";
|
phpEnv.ZABBIX_CONFIG = zabbixConfig;
|
||||||
extraConfig = ''
|
settings = {
|
||||||
listen.owner = ${config.services.httpd.user};
|
"listen.owner" = config.services.httpd.user;
|
||||||
listen.group = ${config.services.httpd.group};
|
"listen.group" = config.services.httpd.group;
|
||||||
user = ${user};
|
} // cfg.poolConfig;
|
||||||
group = ${config.services.httpd.group};
|
|
||||||
env[ZABBIX_CONFIG] = ${zabbixConfig}
|
|
||||||
${cfg.poolConfig}
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
|
|
||||||
services.httpd = {
|
services.httpd = {
|
||||||
|
|
|
@ -7,17 +7,20 @@ let
|
||||||
|
|
||||||
runtimeDir = "/run/phpfpm";
|
runtimeDir = "/run/phpfpm";
|
||||||
|
|
||||||
|
toStr = value:
|
||||||
|
if true == value then "yes"
|
||||||
|
else if false == value then "no"
|
||||||
|
else toString value;
|
||||||
|
|
||||||
fpmCfgFile = pool: poolOpts: pkgs.writeText "phpfpm-${pool}.conf" ''
|
fpmCfgFile = pool: poolOpts: pkgs.writeText "phpfpm-${pool}.conf" ''
|
||||||
[global]
|
[global]
|
||||||
error_log = syslog
|
${concatStringsSep "\n" (mapAttrsToList (n: v: "${n} = ${toStr v}") cfg.settings)}
|
||||||
daemonize = no
|
${optionalString (cfg.extraConfig != null) cfg.extraConfig}
|
||||||
${cfg.extraConfig}
|
|
||||||
|
|
||||||
[${pool}]
|
[${pool}]
|
||||||
listen = ${poolOpts.socket}
|
${concatStringsSep "\n" (mapAttrsToList (n: v: "${n} = ${toStr v}") poolOpts.settings)}
|
||||||
user = ${poolOpts.user}
|
${concatStringsSep "\n" (mapAttrsToList (n: v: "env[${n}] = ${toStr v}") poolOpts.phpEnv)}
|
||||||
group = ${poolOpts.group}
|
${optionalString (poolOpts.extraConfig != null) poolOpts.extraConfig}
|
||||||
${poolOpts.extraConfig}
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
phpIni = poolOpts: pkgs.runCommand "php.ini" {
|
phpIni = poolOpts: pkgs.runCommand "php.ini" {
|
||||||
|
@ -31,7 +34,7 @@ let
|
||||||
cat $phpPackage/etc/php.ini $nixDefaultsPath $phpOptionsPath > $out
|
cat $phpPackage/etc/php.ini $nixDefaultsPath $phpOptionsPath > $out
|
||||||
'';
|
'';
|
||||||
|
|
||||||
poolOpts = { lib, name, ... }:
|
poolOpts = { name, ... }:
|
||||||
let
|
let
|
||||||
poolOpts = cfg.pools."${name}";
|
poolOpts = cfg.pools."${name}";
|
||||||
in
|
in
|
||||||
|
@ -73,6 +76,22 @@ let
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
phpEnv = lib.mkOption {
|
||||||
|
type = with types; attrsOf str;
|
||||||
|
default = {};
|
||||||
|
description = ''
|
||||||
|
Environment variables used for this PHP-FPM pool.
|
||||||
|
'';
|
||||||
|
example = literalExample ''
|
||||||
|
{
|
||||||
|
HOSTNAME = "$HOSTNAME";
|
||||||
|
TMP = "/tmp";
|
||||||
|
TMPDIR = "/tmp";
|
||||||
|
TEMP = "/tmp";
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
user = mkOption {
|
user = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
description = "User account under which this pool runs.";
|
description = "User account under which this pool runs.";
|
||||||
|
@ -83,17 +102,30 @@ let
|
||||||
description = "Group account under which this pool runs.";
|
description = "Group account under which this pool runs.";
|
||||||
};
|
};
|
||||||
|
|
||||||
extraConfig = mkOption {
|
settings = mkOption {
|
||||||
type = types.lines;
|
type = with types; attrsOf (oneOf [ str int bool ]);
|
||||||
example = ''
|
default = {};
|
||||||
pm = dynamic
|
description = ''
|
||||||
pm.max_children = 75
|
PHP-FPM pool directives. Refer to the "List of pool directives" section of
|
||||||
pm.start_servers = 10
|
<link xlink:href="https://www.php.net/manual/en/install.fpm.configuration.php"/>
|
||||||
pm.min_spare_servers = 5
|
for details. Note that settings names must be enclosed in quotes (e.g.
|
||||||
pm.max_spare_servers = 20
|
<literal>"pm.max_children"</literal> instead of <literal>pm.max_children</literal>).
|
||||||
pm.max_requests = 500
|
|
||||||
'';
|
'';
|
||||||
|
example = literalExample ''
|
||||||
|
{
|
||||||
|
"pm" = "dynamic";
|
||||||
|
"pm.max_children" = 75;
|
||||||
|
"pm.start_servers" = 10;
|
||||||
|
"pm.min_spare_servers" = 5;
|
||||||
|
"pm.max_spare_servers" = 20;
|
||||||
|
"pm.max_requests" = 500;
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
extraConfig = mkOption {
|
||||||
|
type = with types; nullOr lines;
|
||||||
|
default = null;
|
||||||
description = ''
|
description = ''
|
||||||
Extra lines that go into the pool configuration.
|
Extra lines that go into the pool configuration.
|
||||||
See the documentation on <literal>php-fpm.conf</literal> for
|
See the documentation on <literal>php-fpm.conf</literal> for
|
||||||
|
@ -105,6 +137,12 @@ let
|
||||||
config = {
|
config = {
|
||||||
socket = if poolOpts.listen == "" then "${runtimeDir}/${name}.sock" else poolOpts.listen;
|
socket = if poolOpts.listen == "" then "${runtimeDir}/${name}.sock" else poolOpts.listen;
|
||||||
group = mkDefault poolOpts.user;
|
group = mkDefault poolOpts.user;
|
||||||
|
|
||||||
|
settings = mapAttrs (name: mkDefault){
|
||||||
|
listen = poolOpts.socket;
|
||||||
|
user = poolOpts.user;
|
||||||
|
group = poolOpts.group;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -112,9 +150,22 @@ in {
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
services.phpfpm = {
|
services.phpfpm = {
|
||||||
|
settings = mkOption {
|
||||||
|
type = with types; attrsOf (oneOf [ str int bool ]);
|
||||||
|
default = {};
|
||||||
|
description = ''
|
||||||
|
PHP-FPM global directives. Refer to the "List of global php-fpm.conf directives" section of
|
||||||
|
<link xlink:href="https://www.php.net/manual/en/install.fpm.configuration.php"/>
|
||||||
|
for details. Note that settings names must be enclosed in quotes (e.g.
|
||||||
|
<literal>"pm.max_children"</literal> instead of <literal>pm.max_children</literal>).
|
||||||
|
You need not specify the options <literal>error_log</literal> or
|
||||||
|
<literal>daemonize</literal> here, since they are generated by NixOS.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
extraConfig = mkOption {
|
extraConfig = mkOption {
|
||||||
type = types.lines;
|
type = with types; nullOr lines;
|
||||||
default = "";
|
default = null;
|
||||||
description = ''
|
description = ''
|
||||||
Extra configuration that should be put in the global section of
|
Extra configuration that should be put in the global section of
|
||||||
the PHP-FPM configuration file. Do not specify the options
|
the PHP-FPM configuration file. Do not specify the options
|
||||||
|
@ -140,8 +191,9 @@ in {
|
||||||
''
|
''
|
||||||
date.timezone = "CET"
|
date.timezone = "CET"
|
||||||
'';
|
'';
|
||||||
description =
|
description = ''
|
||||||
"Options appended to the PHP configuration file <filename>php.ini</filename>.";
|
Options appended to the PHP configuration file <filename>php.ini</filename>.
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
pools = mkOption {
|
pools = mkOption {
|
||||||
|
@ -153,13 +205,13 @@ in {
|
||||||
user = "php";
|
user = "php";
|
||||||
group = "php";
|
group = "php";
|
||||||
phpPackage = pkgs.php;
|
phpPackage = pkgs.php;
|
||||||
extraConfig = '''
|
settings = '''
|
||||||
pm = dynamic
|
"pm" = "dynamic";
|
||||||
pm.max_children = 75
|
"pm.max_children" = 75;
|
||||||
pm.start_servers = 10
|
"pm.start_servers" = 10;
|
||||||
pm.min_spare_servers = 5
|
"pm.min_spare_servers" = 5;
|
||||||
pm.max_spare_servers = 20
|
"pm.max_spare_servers" = 20;
|
||||||
pm.max_requests = 500
|
"pm.max_requests" = 500;
|
||||||
''';
|
''';
|
||||||
}
|
}
|
||||||
}'';
|
}'';
|
||||||
|
@ -175,10 +227,21 @@ in {
|
||||||
|
|
||||||
warnings =
|
warnings =
|
||||||
mapAttrsToList (pool: poolOpts: ''
|
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.
|
Using config.services.phpfpm.pools.${pool}.listen is deprecated and will become unsupported in a future release. 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)
|
'') (filterAttrs (pool: poolOpts: poolOpts.listen != "") cfg.pools) ++
|
||||||
|
mapAttrsToList (pool: poolOpts: ''
|
||||||
|
Using config.services.phpfpm.pools.${pool}.extraConfig is deprecated and will become unsupported in a future release. Please migrate your configuration to config.services.phpfpm.pools.${pool}.settings.
|
||||||
|
'') (filterAttrs (pool: poolOpts: poolOpts.extraConfig != null) cfg.pools) ++
|
||||||
|
optional (cfg.extraConfig != null) ''
|
||||||
|
Using config.services.phpfpm.extraConfig is deprecated and will become unsupported in a future release. Please migrate your configuration to config.services.phpfpm.settings.
|
||||||
|
''
|
||||||
;
|
;
|
||||||
|
|
||||||
|
services.phpfpm.settings = {
|
||||||
|
error_log = "syslog";
|
||||||
|
daemonize = false;
|
||||||
|
};
|
||||||
|
|
||||||
systemd.slices.phpfpm = {
|
systemd.slices.phpfpm = {
|
||||||
description = "PHP FastCGI Process manager pools slice";
|
description = "PHP FastCGI Process manager pools slice";
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue