diff options
author | talyz <kim.lindberger@gmail.com> | 2020-04-05 15:56:28 +0200 |
---|---|---|
committer | talyz <kim.lindberger@gmail.com> | 2020-04-05 16:46:38 +0200 |
commit | ca8b8a26e9b2d025ab7d7ed388e9ae7161681660 (patch) | |
tree | 55a137aecef902a8b5e76b313a9c406080fdb5b7 | |
parent | 8d2e5d5cd6036819eeda38ea4a8237c2e05bd036 (diff) | |
download | nixpkgs-ca8b8a26e9b2d025ab7d7ed388e9ae7161681660.tar nixpkgs-ca8b8a26e9b2d025ab7d7ed388e9ae7161681660.tar.gz nixpkgs-ca8b8a26e9b2d025ab7d7ed388e9ae7161681660.tar.bz2 nixpkgs-ca8b8a26e9b2d025ab7d7ed388e9ae7161681660.tar.lz nixpkgs-ca8b8a26e9b2d025ab7d7ed388e9ae7161681660.tar.xz nixpkgs-ca8b8a26e9b2d025ab7d7ed388e9ae7161681660.tar.zst nixpkgs-ca8b8a26e9b2d025ab7d7ed388e9ae7161681660.zip |
php: Add enabledExtensions attribute to PHP derivations
This provides a means to build a PHP package based on a list of extensions from another. For example, to generate a package with all default extensions enabled, except opcache, but with ImageMagick: php.withExtensions (e: (lib.filter (e: e != php.extensions.opcache) php.enabledExtensions) ++ [ e.imagick ])
-rw-r--r-- | doc/languages-frameworks/php.section.md | 15 | ||||
-rw-r--r-- | pkgs/development/interpreters/php/default.nix | 12 |
2 files changed, 21 insertions, 6 deletions
diff --git a/doc/languages-frameworks/php.section.md b/doc/languages-frameworks/php.section.md index cc98c760aec..a302a9a7f87 100644 --- a/doc/languages-frameworks/php.section.md +++ b/doc/languages-frameworks/php.section.md @@ -48,6 +48,21 @@ enabled: php.withExtensions (e: with e; [ imagick opcache ]) ``` +Note that this will give you a package with _only_ opcache and +ImageMagick, none of the other extensions which are enabled by default +in the `php` package will be available. + +To enable building on a previous PHP package, the currently enabled +extensions are made available in its `enabledExtensions` +attribute. For example, to generate a package with all default +extensions enabled, except opcache, but with ImageMagick: + +```nix +php.withExtensions (e: + (lib.filter (e: e != php.extensions.opcache) php.enabledExtensions) + ++ [ e.imagick ]) +``` + If you want a PHP build with extra configuration in the `php.ini` file, you can use `php.buildEnv`. This function takes two named and optional parameters: `extensions` and `extraConfig`. `extensions` diff --git a/pkgs/development/interpreters/php/default.nix b/pkgs/development/interpreters/php/default.nix index e29f240ca55..d260a90e8ea 100644 --- a/pkgs/development/interpreters/php/default.nix +++ b/pkgs/development/interpreters/php/default.nix @@ -158,7 +158,7 @@ let buildEnv = { extensions ? (_: []), extraConfig ? "" }: let getExtName = ext: lib.removePrefix "php-" (builtins.parseDrvName ext.name).name; - extList = extensions php-packages.extensions; + enabledExtensions = extensions php-packages.extensions; # Generate extension load configuration snippets from the # extension parameter. This is an attrset suitable for use @@ -178,9 +178,9 @@ let deps = lib.optionals (ext ? internalDeps) (map getExtName ext.internalDeps); }) - extList); + enabledExtensions); - extNames = map getExtName extList; + extNames = map getExtName enabledExtensions; extraInit = writeText "custom-php.ini" '' ${lib.concatStringsSep "\n" (lib.textClosureList extensionTexts extNames)} @@ -189,11 +189,10 @@ let in symlinkJoin { name = "php-with-extensions-${version}"; - inherit version; - inherit (php) dev; + inherit (php) version dev; nativeBuildInputs = [ makeWrapper ]; passthru = { - inherit buildEnv withExtensions; + inherit buildEnv withExtensions enabledExtensions; inherit (php-packages) packages extensions; }; paths = [ php ]; @@ -212,6 +211,7 @@ let in php.overrideAttrs (_: { passthru = { + enabledExtensions = []; inherit buildEnv withExtensions; inherit (php-packages) packages extensions; }; |