mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-11-10 08:39:08 +03:00
nixos/nextcloud: make php settings additive
Right now, the settings aren't additive which means that when I do services.nextcloud.phpOptions."opcache.interned_strings_buffer = "23"; all other options are discarded because of how the module system works. This isn't very nice in this case, though because wanting to override a single option doesn't mean I want to discard the rest of the - reasonable - defaults. Hence, the settings are showed as default in the option's manual section, but are added with normal priority. That means, to override _all_ options at once, an expression like services.nextcloud.phpOptions = mkForce { /* ... */ }; is needed. This is also way more intuitive IMHO because the `mkForce` explicitly tells that everything will be modified. Also, APCu enable and the memory & file-size limits are also written into `services.nextcloud.phpOptions` rather than adding them silently before passing all options to the PHP package. This has the benefit that users will realize on evaluation time that they configured options that would otherwise be set by the module on its own.
This commit is contained in:
parent
ed02e79bbe
commit
2ddb1453e6
@ -72,6 +72,22 @@
|
||||
|
||||
- The [services.caddy.acmeCA](#opt-services.caddy.acmeCA) option now defaults to `null` instead of `"https://acme-v02.api.letsencrypt.org/directory"`, to use all of Caddy's default ACME CAs and enable Caddy's automatic issuer fallback feature by default, as recommended by upstream.
|
||||
|
||||
- The default priorities of [`services.nextcloud.phpOptions`](#opt-services.nextcloud.phpOptions) have changed. This means that e.g.
|
||||
`services.nextcloud.phpOptions."opcache.interned_strings_buffer" = "23";` doesn't discard all of the other defaults from this option
|
||||
anymore. The attribute values of `phpOptions` are still defaults, these can be overridden as shown here.
|
||||
|
||||
To override all of the options (including including `upload_max_filesize`, `post_max_size`
|
||||
and `memory_limit` which all point to [`services.nextcloud.maxUploadSize`](#opt-services.nextcloud.maxUploadSize)
|
||||
by default) can be done like this:
|
||||
|
||||
```nix
|
||||
{
|
||||
services.nextcloud.phpOptions = lib.mkForce {
|
||||
/* ... */
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
- `php80` is no longer supported due to upstream not supporting this version anymore.
|
||||
|
||||
- PHP now defaults to PHP 8.2, updated from 8.1.
|
||||
|
@ -8,6 +8,21 @@ let
|
||||
|
||||
jsonFormat = pkgs.formats.json {};
|
||||
|
||||
defaultPHPSettings = {
|
||||
short_open_tag = "Off";
|
||||
expose_php = "Off";
|
||||
error_reporting = "E_ALL & ~E_DEPRECATED & ~E_STRICT";
|
||||
display_errors = "stderr";
|
||||
"opcache.enable_cli" = "1";
|
||||
"opcache.interned_strings_buffer" = "8";
|
||||
"opcache.max_accelerated_files" = "10000";
|
||||
"opcache.memory_consumption" = "128";
|
||||
"opcache.revalidate_freq" = "1";
|
||||
"opcache.fast_shutdown" = "1";
|
||||
"openssl.cafile" = "/etc/ssl/certs/ca-certificates.crt";
|
||||
catch_workers_output = "yes";
|
||||
};
|
||||
|
||||
inherit (cfg) datadir;
|
||||
|
||||
phpPackage = cfg.phpPackage.buildEnv {
|
||||
@ -26,22 +41,13 @@ let
|
||||
++ optional cfg.caching.memcached memcached
|
||||
)
|
||||
++ cfg.phpExtraExtensions all; # Enabled by user
|
||||
extraConfig = toKeyValue phpOptions;
|
||||
extraConfig = toKeyValue cfg.phpOptions;
|
||||
};
|
||||
|
||||
toKeyValue = generators.toKeyValue {
|
||||
mkKeyValue = generators.mkKeyValueDefault {} " = ";
|
||||
};
|
||||
|
||||
phpOptions = {
|
||||
upload_max_filesize = cfg.maxUploadSize;
|
||||
post_max_size = cfg.maxUploadSize;
|
||||
memory_limit = cfg.maxUploadSize;
|
||||
} // cfg.phpOptions
|
||||
// optionalAttrs cfg.caching.apcu {
|
||||
"apc.enable_cli" = "1";
|
||||
};
|
||||
|
||||
occ = pkgs.writeScriptBin "nextcloud-occ" ''
|
||||
#! ${pkgs.runtimeShell}
|
||||
cd ${cfg.package}
|
||||
@ -263,22 +269,33 @@ in {
|
||||
|
||||
phpOptions = mkOption {
|
||||
type = types.attrsOf types.str;
|
||||
default = {
|
||||
short_open_tag = "Off";
|
||||
expose_php = "Off";
|
||||
error_reporting = "E_ALL & ~E_DEPRECATED & ~E_STRICT";
|
||||
display_errors = "stderr";
|
||||
"opcache.enable_cli" = "1";
|
||||
"opcache.interned_strings_buffer" = "8";
|
||||
"opcache.max_accelerated_files" = "10000";
|
||||
"opcache.memory_consumption" = "128";
|
||||
"opcache.revalidate_freq" = "1";
|
||||
"opcache.fast_shutdown" = "1";
|
||||
"openssl.cafile" = "/etc/ssl/certs/ca-certificates.crt";
|
||||
catch_workers_output = "yes";
|
||||
};
|
||||
defaultText = literalExpression (generators.toPretty { } defaultPHPSettings);
|
||||
description = lib.mdDoc ''
|
||||
Options for PHP's php.ini file for nextcloud.
|
||||
|
||||
Please note that this option is _additive_ on purpose while the
|
||||
attribute values inside the default are option defaults: that means that
|
||||
|
||||
```nix
|
||||
{
|
||||
services.nextcloud.phpOptions."opcache.interned_strings_buffer" = "23";
|
||||
}
|
||||
```
|
||||
|
||||
will override the `php.ini` option `opcache.interned_strings_buffer` without
|
||||
discarding the rest of the defaults.
|
||||
|
||||
Overriding all of `phpOptions` (including `upload_max_filesize`, `post_max_size`
|
||||
and `memory_limit` which all point to [](#opt-services.nextcloud.maxUploadSize)
|
||||
by default) can be done like this:
|
||||
|
||||
```nix
|
||||
{
|
||||
services.nextcloud.phpOptions = lib.mkForce {
|
||||
/* ... */
|
||||
};
|
||||
}
|
||||
```
|
||||
'';
|
||||
};
|
||||
|
||||
@ -750,6 +767,18 @@ in {
|
||||
services.nextcloud.phpPackage =
|
||||
if versionOlder cfg.package.version "26" then pkgs.php81
|
||||
else pkgs.php82;
|
||||
|
||||
services.nextcloud.phpOptions = mkMerge [
|
||||
(mapAttrs (const mkOptionDefault) defaultPHPSettings)
|
||||
{
|
||||
upload_max_filesize = cfg.maxUploadSize;
|
||||
post_max_size = cfg.maxUploadSize;
|
||||
memory_limit = cfg.maxUploadSize;
|
||||
}
|
||||
(mkIf cfg.caching.apcu {
|
||||
"apc.enable_cli" = "1";
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
{ assertions = [
|
||||
|
Loading…
Reference in New Issue
Block a user