treewide: Format all Nix files
Format all Nix files using the officially approved formatter,
making the CI check introduced in the previous commit succeed:
nix-build ci -A fmt.check
This is the next step of the of the [implementation](https://github.com/NixOS/nixfmt/issues/153)
of the accepted [RFC 166](https://github.com/NixOS/rfcs/pull/166).
This commit will lead to merge conflicts for a number of PRs,
up to an estimated ~1100 (~33%) among the PRs with activity in the past 2
months, but that should be lower than what it would be without the previous
[partial treewide format](https://github.com/NixOS/nixpkgs/pull/322537).
Merge conflicts caused by this commit can now automatically be resolved while rebasing using the
[auto-rebase script](8616af08d9/maintainers/scripts/auto-rebase).
If you run into any problems regarding any of this, please reach out to the
[formatting team](https://nixos.org/community/teams/formatting/) by
pinging @NixOS/nix-formatting.
This commit is contained in:
@@ -1,4 +1,9 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
with lib;
|
||||
|
||||
@@ -7,31 +12,42 @@ let
|
||||
|
||||
runtimeDir = "/run/phpfpm";
|
||||
|
||||
toStr = value:
|
||||
if true == value then "yes"
|
||||
else if false == value then "no"
|
||||
else toString value;
|
||||
toStr =
|
||||
value:
|
||||
if true == value then
|
||||
"yes"
|
||||
else if false == value then
|
||||
"no"
|
||||
else
|
||||
toString value;
|
||||
|
||||
fpmCfgFile = pool: poolOpts: pkgs.writeText "phpfpm-${pool}.conf" ''
|
||||
[global]
|
||||
${concatStringsSep "\n" (mapAttrsToList (n: v: "${n} = ${toStr v}") cfg.settings)}
|
||||
${optionalString (cfg.extraConfig != null) cfg.extraConfig}
|
||||
fpmCfgFile =
|
||||
pool: poolOpts:
|
||||
pkgs.writeText "phpfpm-${pool}.conf" ''
|
||||
[global]
|
||||
${concatStringsSep "\n" (mapAttrsToList (n: v: "${n} = ${toStr v}") cfg.settings)}
|
||||
${optionalString (cfg.extraConfig != null) cfg.extraConfig}
|
||||
|
||||
[${pool}]
|
||||
${concatStringsSep "\n" (mapAttrsToList (n: v: "${n} = ${toStr v}") poolOpts.settings)}
|
||||
${concatStringsSep "\n" (mapAttrsToList (n: v: "env[${n}] = ${toStr v}") poolOpts.phpEnv)}
|
||||
${optionalString (poolOpts.extraConfig != null) poolOpts.extraConfig}
|
||||
'';
|
||||
[${pool}]
|
||||
${concatStringsSep "\n" (mapAttrsToList (n: v: "${n} = ${toStr v}") poolOpts.settings)}
|
||||
${concatStringsSep "\n" (mapAttrsToList (n: v: "env[${n}] = ${toStr v}") poolOpts.phpEnv)}
|
||||
${optionalString (poolOpts.extraConfig != null) poolOpts.extraConfig}
|
||||
'';
|
||||
|
||||
phpIni = poolOpts: pkgs.runCommand "php.ini" {
|
||||
inherit (poolOpts) phpPackage phpOptions;
|
||||
preferLocalBuild = true;
|
||||
passAsFile = [ "phpOptions" ];
|
||||
} ''
|
||||
cat ${poolOpts.phpPackage}/etc/php.ini $phpOptionsPath > $out
|
||||
'';
|
||||
phpIni =
|
||||
poolOpts:
|
||||
pkgs.runCommand "php.ini"
|
||||
{
|
||||
inherit (poolOpts) phpPackage phpOptions;
|
||||
preferLocalBuild = true;
|
||||
passAsFile = [ "phpOptions" ];
|
||||
}
|
||||
''
|
||||
cat ${poolOpts.phpPackage}/etc/php.ini $phpOptionsPath > $out
|
||||
'';
|
||||
|
||||
poolOpts = { name, ... }:
|
||||
poolOpts =
|
||||
{ name, ... }:
|
||||
let
|
||||
poolOpts = cfg.pools.${name};
|
||||
in
|
||||
@@ -77,7 +93,7 @@ let
|
||||
|
||||
phpEnv = lib.mkOption {
|
||||
type = with types; attrsOf str;
|
||||
default = {};
|
||||
default = { };
|
||||
description = ''
|
||||
Environment variables used for this PHP-FPM pool.
|
||||
'';
|
||||
@@ -102,8 +118,14 @@ let
|
||||
};
|
||||
|
||||
settings = mkOption {
|
||||
type = with types; attrsOf (oneOf [ str int bool ]);
|
||||
default = {};
|
||||
type =
|
||||
with types;
|
||||
attrsOf (oneOf [
|
||||
str
|
||||
int
|
||||
bool
|
||||
]);
|
||||
default = { };
|
||||
description = ''
|
||||
PHP-FPM pool directives. Refer to the "List of pool directives" section of
|
||||
<https://www.php.net/manual/en/install.fpm.configuration.php>
|
||||
@@ -138,7 +160,7 @@ let
|
||||
group = mkDefault poolOpts.user;
|
||||
phpOptions = mkBefore cfg.phpOptions;
|
||||
|
||||
settings = mapAttrs (name: mkDefault){
|
||||
settings = mapAttrs (name: mkDefault) {
|
||||
listen = poolOpts.socket;
|
||||
user = poolOpts.user;
|
||||
group = poolOpts.group;
|
||||
@@ -146,7 +168,8 @@ let
|
||||
};
|
||||
};
|
||||
|
||||
in {
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
(mkRemovedOptionModule [ "services" "phpfpm" "poolConfigs" ] "Use services.phpfpm.pools instead.")
|
||||
(mkRemovedOptionModule [ "services" "phpfpm" "phpIni" ] "")
|
||||
@@ -155,8 +178,14 @@ in {
|
||||
options = {
|
||||
services.phpfpm = {
|
||||
settings = mkOption {
|
||||
type = with types; attrsOf (oneOf [ str int bool ]);
|
||||
default = {};
|
||||
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
|
||||
<https://www.php.net/manual/en/install.fpm.configuration.php>
|
||||
@@ -184,10 +213,9 @@ in {
|
||||
phpOptions = mkOption {
|
||||
type = types.lines;
|
||||
default = "";
|
||||
example =
|
||||
''
|
||||
date.timezone = "CET"
|
||||
'';
|
||||
example = ''
|
||||
date.timezone = "CET"
|
||||
'';
|
||||
description = ''
|
||||
Options appended to the PHP configuration file {file}`php.ini`.
|
||||
'';
|
||||
@@ -195,23 +223,23 @@ in {
|
||||
|
||||
pools = mkOption {
|
||||
type = types.attrsOf (types.submodule poolOpts);
|
||||
default = {};
|
||||
default = { };
|
||||
example = literalExpression ''
|
||||
{
|
||||
mypool = {
|
||||
user = "php";
|
||||
group = "php";
|
||||
phpPackage = pkgs.php;
|
||||
settings = {
|
||||
"pm" = "dynamic";
|
||||
"pm.max_children" = 75;
|
||||
"pm.start_servers" = 10;
|
||||
"pm.min_spare_servers" = 5;
|
||||
"pm.max_spare_servers" = 20;
|
||||
"pm.max_requests" = 500;
|
||||
};
|
||||
}
|
||||
}'';
|
||||
{
|
||||
mypool = {
|
||||
user = "php";
|
||||
group = "php";
|
||||
phpPackage = pkgs.php;
|
||||
settings = {
|
||||
"pm" = "dynamic";
|
||||
"pm.max_children" = 75;
|
||||
"pm.start_servers" = 10;
|
||||
"pm.min_spare_servers" = 5;
|
||||
"pm.max_spare_servers" = 20;
|
||||
"pm.max_requests" = 500;
|
||||
};
|
||||
}
|
||||
}'';
|
||||
description = ''
|
||||
PHP-FPM pools. If no pools are defined, the PHP-FPM
|
||||
service is disabled.
|
||||
@@ -220,19 +248,18 @@ in {
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf (cfg.pools != {}) {
|
||||
config = mkIf (cfg.pools != { }) {
|
||||
|
||||
warnings =
|
||||
mapAttrsToList (pool: poolOpts: ''
|
||||
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) ++
|
||||
mapAttrsToList (pool: poolOpts: ''
|
||||
'') (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) ''
|
||||
'') (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";
|
||||
@@ -248,31 +275,34 @@ in {
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
};
|
||||
|
||||
systemd.services = mapAttrs' (pool: poolOpts:
|
||||
systemd.services = mapAttrs' (
|
||||
pool: poolOpts:
|
||||
nameValuePair "phpfpm-${pool}" {
|
||||
description = "PHP FastCGI Process Manager service for pool ${pool}";
|
||||
after = [ "network.target" ];
|
||||
wantedBy = [ "phpfpm.target" ];
|
||||
partOf = [ "phpfpm.target" ];
|
||||
documentation = [ "man:php-fpm(8)" ];
|
||||
serviceConfig = let
|
||||
cfgFile = fpmCfgFile pool poolOpts;
|
||||
iniFile = phpIni poolOpts;
|
||||
in {
|
||||
Slice = "system-phpfpm.slice";
|
||||
PrivateDevices = true;
|
||||
PrivateTmp = true;
|
||||
ProtectSystem = "full";
|
||||
ProtectHome = true;
|
||||
# XXX: We need AF_NETLINK to make the sendmail SUID binary from postfix work
|
||||
RestrictAddressFamilies = "AF_UNIX AF_INET AF_INET6 AF_NETLINK";
|
||||
Type = "notify";
|
||||
ExecStart = "${poolOpts.phpPackage}/bin/php-fpm -y ${cfgFile} -c ${iniFile}";
|
||||
ExecReload = "${pkgs.coreutils}/bin/kill -USR2 $MAINPID";
|
||||
RuntimeDirectory = "phpfpm";
|
||||
RuntimeDirectoryPreserve = true; # Relevant when multiple processes are running
|
||||
Restart = "always";
|
||||
};
|
||||
serviceConfig =
|
||||
let
|
||||
cfgFile = fpmCfgFile pool poolOpts;
|
||||
iniFile = phpIni poolOpts;
|
||||
in
|
||||
{
|
||||
Slice = "system-phpfpm.slice";
|
||||
PrivateDevices = true;
|
||||
PrivateTmp = true;
|
||||
ProtectSystem = "full";
|
||||
ProtectHome = true;
|
||||
# XXX: We need AF_NETLINK to make the sendmail SUID binary from postfix work
|
||||
RestrictAddressFamilies = "AF_UNIX AF_INET AF_INET6 AF_NETLINK";
|
||||
Type = "notify";
|
||||
ExecStart = "${poolOpts.phpPackage}/bin/php-fpm -y ${cfgFile} -c ${iniFile}";
|
||||
ExecReload = "${pkgs.coreutils}/bin/kill -USR2 $MAINPID";
|
||||
RuntimeDirectory = "phpfpm";
|
||||
RuntimeDirectoryPreserve = true; # Relevant when multiple processes are running
|
||||
Restart = "always";
|
||||
};
|
||||
}
|
||||
) cfg.pools;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user