about summary refs log tree commit diff
path: root/nixos/modules/services
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/modules/services
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/modules/services')
-rw-r--r--nixos/modules/services/mail/roundcube.nix2
-rw-r--r--nixos/modules/services/web-apps/nextcloud.nix4
2 files changed, 3 insertions, 3 deletions
diff --git a/nixos/modules/services/mail/roundcube.nix b/nixos/modules/services/mail/roundcube.nix
index 21e92cfee016..ed1439745ac9 100644
--- a/nixos/modules/services/mail/roundcube.nix
+++ b/nixos/modules/services/mail/roundcube.nix
@@ -7,7 +7,7 @@ let
   fpm = config.services.phpfpm.pools.roundcube;
   localDB = cfg.database.host == "localhost";
   user = cfg.database.username;
-  phpWithPspell = pkgs.php.withExtensions (e: [ e.pspell ] ++ pkgs.php.enabledExtensions);
+  phpWithPspell = pkgs.php.withExtensions ({ enabled, all }: [ all.pspell ] ++ enabled);
 in
 {
   options.services.roundcube = {
diff --git a/nixos/modules/services/web-apps/nextcloud.nix b/nixos/modules/services/web-apps/nextcloud.nix
index 5f6f2bc7a16d..f826096bf608 100644
--- a/nixos/modules/services/web-apps/nextcloud.nix
+++ b/nixos/modules/services/web-apps/nextcloud.nix
@@ -11,8 +11,8 @@ let
       base = pkgs.php74;
     in
       base.buildEnv {
-        extensions = e: with e;
-          base.enabledExtensions ++ [
+        extensions = { enabled, all }: with all;
+          enabled ++ [
             apcu redis memcached imagick
           ];
         extraConfig = phpOptionsStr;