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

This commit is contained in:
Aaron Andersen
2019-08-23 07:56:21 -04:00
parent 2b5f663015
commit 62b774a700
9 changed files with 36 additions and 22 deletions
@@ -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";
};