phpfpm service: restructured pool configuration

From @fpletz: Keep poolConfigs option for backwards-compatibility.

The original commit 6b3f5b5a421fe3422e9ef63a3fd690178c36163e was previously
reverted by c7860cae1a4b54f4b54339142472f00f861fa055 but the issues were
resolved.

authored by

Al Zohali and committed by
Franz Pletz
2aba1c49 7c9a0bf5

+56 -3
+1 -1
nixos/modules/module-list.nix
··· 476 ./services/web-servers/lighttpd/gitweb.nix 477 ./services/web-servers/lighttpd/inginious.nix 478 ./services/web-servers/nginx/default.nix 479 - ./services/web-servers/phpfpm.nix 480 ./services/web-servers/shellinabox.nix 481 ./services/web-servers/tomcat.nix 482 ./services/web-servers/uwsgi.nix
··· 476 ./services/web-servers/lighttpd/gitweb.nix 477 ./services/web-servers/lighttpd/inginious.nix 478 ./services/web-servers/nginx/default.nix 479 + ./services/web-servers/phpfpm/default.nix 480 ./services/web-servers/shellinabox.nix 481 ./services/web-servers/tomcat.nix 482 ./services/web-servers/uwsgi.nix
+20 -2
nixos/modules/services/web-servers/phpfpm.nix nixos/modules/services/web-servers/phpfpm/default.nix
··· 9 10 pidFile = "${stateDir}/phpfpm.pid"; 11 12 cfgFile = pkgs.writeText "phpfpm.conf" '' 13 [global] 14 pid = ${pidFile} 15 error_log = syslog 16 daemonize = yes 17 ${cfg.extraConfig} 18 19 ${concatStringsSep "\n" (mapAttrsToList (n: v: "[${n}]\n${v}") cfg.poolConfigs)} 20 ''; ··· 62 }; 63 64 poolConfigs = mkOption { 65 - type = types.attrsOf types.lines; 66 default = {}; 67 example = literalExample '' 68 { mypool = ''' 69 listen = /run/phpfpm/mypool ··· 84 the phpfpm service is disabled. 85 ''; 86 }; 87 }; 88 }; 89 90 - config = mkIf (cfg.poolConfigs != {}) { 91 92 systemd.services.phpfpm = { 93 wantedBy = [ "multi-user.target" ];
··· 9 10 pidFile = "${stateDir}/phpfpm.pid"; 11 12 + mkPool = n: p: '' 13 + [${n}] 14 + listen = ${p.listen} 15 + ${p.extraConfig} 16 + ''; 17 + 18 cfgFile = pkgs.writeText "phpfpm.conf" '' 19 [global] 20 pid = ${pidFile} 21 error_log = syslog 22 daemonize = yes 23 ${cfg.extraConfig} 24 + 25 + ${concatStringsSep "\n" (mapAttrsToList mkPool cfg.pools)} 26 27 ${concatStringsSep "\n" (mapAttrsToList (n: v: "[${n}]\n${v}") cfg.poolConfigs)} 28 ''; ··· 70 }; 71 72 poolConfigs = mkOption { 73 default = {}; 74 + type = types.attrsOf types.lines; 75 example = literalExample '' 76 { mypool = ''' 77 listen = /run/phpfpm/mypool ··· 92 the phpfpm service is disabled. 93 ''; 94 }; 95 + 96 + pools = mkOption { 97 + type = types.attrsOf (types.submodule (import ./pool-options.nix { 98 + inherit lib; 99 + })); 100 + default = {}; 101 + description = '' 102 + If no pools are defined, the phpfpm service is disabled. 103 + ''; 104 + }; 105 }; 106 }; 107 108 + config = mkIf (cfg.pools != {}) { 109 110 systemd.services.phpfpm = { 111 wantedBy = [ "multi-user.target" ];
+35
nixos/modules/services/web-servers/phpfpm/pool-options.nix
···
··· 1 + { lib }: 2 + 3 + with lib; { 4 + 5 + options = { 6 + 7 + listen = mkOption { 8 + type = types.str; 9 + example = "/path/to/unix/socket"; 10 + description = '' 11 + The address on which to accept FastCGI requests. 12 + ''; 13 + }; 14 + 15 + extraConfig = mkOption { 16 + type = types.lines; 17 + example = '' 18 + user = nobody 19 + pm = dynamic 20 + pm.max_children = 75 21 + pm.start_servers = 10 22 + pm.min_spare_servers = 5 23 + pm.max_spare_servers = 20 24 + pm.max_requests = 500 25 + ''; 26 + 27 + description = '' 28 + Extra lines that go into the pool configuration. 29 + See the documentation on <literal>php-fpm.conf</literal> for 30 + details on configuration directives. 31 + ''; 32 + }; 33 + }; 34 + } 35 +