Skip to content

Commit

Permalink
php.packages: Make packages overridable
Browse files Browse the repository at this point in the history
This will allow patching extensions without having to manually having to patch all occurrences in the dependency tree.
  • Loading branch information
jtojnar committed Dec 16, 2020
1 parent 7e8b2b7 commit b2594c7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
18 changes: 18 additions & 0 deletions doc/languages-frameworks/php.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,21 @@ Example of building `composer` with additional extensions:
enabled ++ (with all; [ imagick redis ]))
).packages.composer
```

### Overriding PHP packages {#ssec-php-user-guide-overriding-packages}

`php-packages.nix` form a scope, allowing us to override the packages defined within. For example, to apply a patch to a `mysqlnd` extension, you can simply pass an overlay-style function to `php`’s `packageOverrides` argument:

```nix
php.override {
packageOverrides = final: prev: {
extensions = prev.extensions // {
mysqlnd = prev.extensions.mysqlnd.overrideAttrs (attrs: {
patches = attrs.patches or [] ++ [
];
});
};
};
}
```
3 changes: 2 additions & 1 deletion pkgs/development/interpreters/php/generic.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ let
, version
, sha256
, extraPatches ? []
, packageOverrides ? (final: prev: {})

# Sapi flags
, cgiSupport ? true
Expand Down Expand Up @@ -50,7 +51,7 @@ let

php-packages = (callPackage ../../../top-level/php-packages.nix {
phpPackage = phpWithExtensions;
});
}).overrideScope' packageOverrides;

allExtensionFunctions = prevExtensionFunctions ++ [ extensions ];
enabledExtensions =
Expand Down

0 comments on commit b2594c7

Please sign in to comment.