Re: [Nix-dev] Custom php.ini for cli calls
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 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) 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 > > > 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-...@lists.science.uu.nlhttp://lists.science.uu.nl/mailman/listinfo/nix-dev > > > ___ > nix-dev mailing list > nix-dev@lists.science.uu.nl > http://lists.science.uu.nl/mailman/listinfo/nix-dev > ___ nix-dev mailing list nix-dev@lists.science.uu.nl http://lists.science.uu.nl/mailman/listinfo/nix-dev
Re: [Nix-dev] Custom php.ini for cli calls
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 list > nix-dev@lists.science.uu.nl > http://lists.science.uu.nl/mailman/listinfo/nix-dev ___ nix-dev mailing list nix-dev@lists.science.uu.nl http://lists.science.uu.nl/mailman/listinfo/nix-dev
Re: [Nix-dev] Custom php.ini for cli calls
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 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 list >> nix-dev@lists.science.uu.nl >> http://lists.science.uu.nl/mailman/listinfo/nix-dev ___ nix-dev mailing list nix-dev@lists.science.uu.nl http://lists.science.uu.nl/mailman/listinfo/nix-dev
[Nix-dev] Custom php.ini for cli calls
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 list nix-dev@lists.science.uu.nl http://lists.science.uu.nl/mailman/listinfo/nix-dev