[Nix-dev] Custom php.ini for cli calls

4levels 4levels at gmail.com
Fri Feb 5 09:41:12 CET 2016


Hi Guillaume,

thanks again for the interesting reply, this would have taken me hours (oh,
it already has) if not days to figure this out myself!  The php --ini call
is actually the solution for me as indeed no config file is being loaded in
cli.  I'm wondering if this is safe as I don't know how sensible php's
defaults are..
The phpfpm service already has a customized ini file being generated (I
can't find this listed when I call "systemctl status phpfpm").  When I
setup an info file containing the phpinfo() function I can view the path of
the customized and loaded config file.

I've updated my scripts to include the -c <path-to-config-file> and that
does the trick, great stuff!

  ${pkgs.php}/bin/php -c ${config.services.phpfpm.phpIni} ...

Thanks again!

Erik

On Thu, Feb 4, 2016 at 5:25 PM Guillaume Maudoux (Layus) <layus.on at gmail.com>
wrote:

> That being said, you can also start php with the right arguments.
> It seems to me that php does not read any configuration file from the
> derivation when it starts.
>
> $ php --ini
> Configuration File (php.ini) Path:
> /nix/store/hr30lz6ziqinsbi525fm9han3lr9nsmj-php-5.6.16/etc
> Loaded Configuration File:         (none)
> Scan for additional .ini files in: /etc
> Additional .ini files parsed:      (none)
>
> so you probably need to put your own php.ini file in /etc or call php -c
> <custom_ini_file>
>
> Nothing to do with the derivation :-).
>
> Layus.
>
> Le 04/02/16 17:14, Guillaume Maudoux (Layus) a écrit :
>
> Hi,
>
> I found a hint on StackOverflow[1], which outlines that php is not the
> product of a makeDerivation, but instead is a composableDerivation.
> More info on these strange beasts can be found in the source itself[2],
> with php being explicitly cited as an exception.
> Once you know it, you notice it at the top of php/default.nix :-).
>
> Basically, overrideDerivation is not available for php; instead you have
> the choice between merge and replace
>
> This works for me :
>
> # In .nixpkgs/config.nix :
> packageOverrides = pkgs: with pkgs; rec {
>    php70 = pkgs.php70.merge (oldAttrs: {
>       installPhase = ''
>           # use the old installPhase if need be
>           ${oldAttrs.installPhase}
>
>           # Add custom stuff
>           echo "Strange option" >> $iniFile
>       '';
>     });
> };
>
> [1]
> http://stackoverflow.com/questions/23660797/nix-composable-derivation-options
> [2]
> https://github.com/NixOS/nixpkgs/blob/master/lib/composable-derivation.nix
>
> Le 04/02/16 15:52, 4levels a écrit :
>
> Hi Nix Devs,
>
> I'm trying to increase the memory_limit settings for php cli calls.
> For the phpfpm calls I've managed (a few months ago) to append my custom
> options to the php.ini file as the phpfpm service has an option to do so.
> However, for php cli calls, the memory_limit value is usually set to
> unlimited, but not with the default config in the nix package: it has a
> value of 128M (instead of the expected -1).
>
> In the php/default.nix I can see that the ini file is generated in the
> installPhase, but I'm failing to override this.
>
> Do you have any suggestions on how to achieve this?
>
>
> Kind regards,
>
> Erik
>
> Working phpfpm custom ini snippet:
>
> # Custom PHP ini file for apc / memcached
> services.phpfpm.phpIni = pkgs.runCommand "php.ini" {
>   options = ''
>     date.timezone = Europe/Brussels
>     extension = "${pkgs.phpPackages.apcu}/lib/php/extensions/apcu.so"
>     max_execution_time = 30
>     post_max_size = 100M
>     upload_max_size = 100M
>     upload_max_filesize = 20M
>     memory_limit = 256M
>     apc.enable = 1
>   '';
> }
> ''
>   cat ${pkgs.php}/etc/php-recommended.ini > $out
>   echo "$options" >> $out
> '';
>
>
>
> _______________________________________________
> nix-dev mailing listnix-dev at lists.science.uu.nlhttp://lists.science.uu.nl/mailman/listinfo/nix-dev
>
>
> _______________________________________________
> nix-dev mailing list
> nix-dev at lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/nix-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.science.uu.nl/pipermail/nix-dev/attachments/20160205/410e0da3/attachment.html 


More information about the nix-dev mailing list