about summary refs log tree commit diff
path: root/nixos/doc/manual
diff options
context:
space:
mode:
authortalyz <kim.lindberger@gmail.com>2020-04-12 23:31:56 +0200
committertalyz <kim.lindberger@gmail.com>2020-04-26 16:43:05 +0200
commit2ba79269590cd186c3ad6e5226c4322de8984d87 (patch)
tree1606c5623b36fd7eb0e9a78b9c7eb2b8b700bb84 /nixos/doc/manual
parentabedfadd7376a2edf59bbfaa7ab101411d042529 (diff)
downloadnixlib-2ba79269590cd186c3ad6e5226c4322de8984d87.tar
nixlib-2ba79269590cd186c3ad6e5226c4322de8984d87.tar.gz
nixlib-2ba79269590cd186c3ad6e5226c4322de8984d87.tar.bz2
nixlib-2ba79269590cd186c3ad6e5226c4322de8984d87.tar.lz
nixlib-2ba79269590cd186c3ad6e5226c4322de8984d87.tar.xz
nixlib-2ba79269590cd186c3ad6e5226c4322de8984d87.tar.zst
nixlib-2ba79269590cd186c3ad6e5226c4322de8984d87.zip
php.buildEnv: Provide a list of currently enabled extensions
Rework withExtensions / buildEnv to handle currently enabled
extensions better and make them compatible with override. They now
accept a function with the named arguments enabled and all, where
enabled is a list of currently enabled extensions and all is the set
of all extensions. This gives us several nice properties:

 - You always get the right version of the list of currently enabled
   extensions

 - Invocations chain

 - It works well with overridden PHP packages - you always get the
   correct versions of extensions

As a contrived example of what's possible, you can add ImageMagick,
then override the version and disable fpm, then disable cgi, and
lastly remove the zip extension like this:

{ pkgs ? (import <nixpkgs>) {} }:
with pkgs;

let
  phpWithImagick = php74.withExtensions ({ all, enabled }: enabled ++ [ all.imagick ]);

  phpWithImagickWithoutFpm743 = phpWithImagick.override {
    version = "7.4.3";
    sha256 = "wVF7pJV4+y3MZMc6Ptx21PxQfEp6xjmYFYTMfTtMbRQ=";
    fpmSupport = false;
  };

  phpWithImagickWithoutFpmZip743 = phpWithImagickWithoutFpm743.withExtensions (
    { enabled, all }:
      lib.filter (e: e != all.zip) enabled);

  phpWithImagickWithoutFpmZipCgi743 = phpWithImagickWithoutFpmZip743.override {
    cgiSupport = false;
  };
in
  phpWithImagickWithoutFpmZipCgi743
Diffstat (limited to 'nixos/doc/manual')
-rw-r--r--nixos/doc/manual/release-notes/rl-2009.xml21
1 files changed, 13 insertions, 8 deletions
diff --git a/nixos/doc/manual/release-notes/rl-2009.xml b/nixos/doc/manual/release-notes/rl-2009.xml
index 3e29c19af8fb..e4e44c8405f3 100644
--- a/nixos/doc/manual/release-notes/rl-2009.xml
+++ b/nixos/doc/manual/release-notes/rl-2009.xml
@@ -135,18 +135,23 @@
    </listitem>
    <listitem>
      <para>
-       Since this release there's an easy way to customize your PHP install to get a much smaller
-       base PHP with only wanted extensions enabled. See the following snippet installing a smaller PHP
-       with the extensions <literal>imagick</literal>, <literal>opcache</literal> and
+       Since this release there's an easy way to customize your PHP
+       install to get a much smaller base PHP with only wanted
+       extensions enabled. See the following snippet installing a
+       smaller PHP with the extensions <literal>imagick</literal>,
+       <literal>opcache</literal>, <literal>pdo</literal> and
        <literal>pdo_mysql</literal> loaded:
 
        <programlisting>
 environment.systemPackages = [
-(pkgs.php.buildEnv { extensions = pp: with pp; [
-    imagick
-    opcache
-    pdo_mysql
-  ]; })
+  (pkgs.php.withExtensions
+    ({ all, ... }: with all; [
+      imagick
+      opcache
+      pdo
+      pdo_mysql
+    ])
+  )
 ];</programlisting>
 
        The default <literal>php</literal> attribute hasn't lost any extensions -