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 476 ./services/web-servers/lighttpd/gitweb.nix 477 477 ./services/web-servers/lighttpd/inginious.nix 478 478 ./services/web-servers/nginx/default.nix 479 - ./services/web-servers/phpfpm.nix 479 + ./services/web-servers/phpfpm/default.nix 480 480 ./services/web-servers/shellinabox.nix 481 481 ./services/web-servers/tomcat.nix 482 482 ./services/web-servers/uwsgi.nix
+20 -2
nixos/modules/services/web-servers/phpfpm.nix nixos/modules/services/web-servers/phpfpm/default.nix
··· 9 9 10 10 pidFile = "${stateDir}/phpfpm.pid"; 11 11 12 + mkPool = n: p: '' 13 + [${n}] 14 + listen = ${p.listen} 15 + ${p.extraConfig} 16 + ''; 17 + 12 18 cfgFile = pkgs.writeText "phpfpm.conf" '' 13 19 [global] 14 20 pid = ${pidFile} 15 21 error_log = syslog 16 22 daemonize = yes 17 23 ${cfg.extraConfig} 24 + 25 + ${concatStringsSep "\n" (mapAttrsToList mkPool cfg.pools)} 18 26 19 27 ${concatStringsSep "\n" (mapAttrsToList (n: v: "[${n}]\n${v}") cfg.poolConfigs)} 20 28 ''; ··· 62 70 }; 63 71 64 72 poolConfigs = mkOption { 65 - type = types.attrsOf types.lines; 66 73 default = {}; 74 + type = types.attrsOf types.lines; 67 75 example = literalExample '' 68 76 { mypool = ''' 69 77 listen = /run/phpfpm/mypool ··· 84 92 the phpfpm service is disabled. 85 93 ''; 86 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 + }; 87 105 }; 88 106 }; 89 107 90 - config = mkIf (cfg.poolConfigs != {}) { 108 + config = mkIf (cfg.pools != {}) { 91 109 92 110 systemd.services.phpfpm = { 93 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 +