Skip to content

Commit 1d220e5

Browse files
agjagj
andauthored
php7[01234].extension.decimal: Override decimal to allow use in PHP 7
Depends on the JSON extension, which was included in PHP starting from version 8, so it's added when building for PHP 7. See: https://www.php.net/manual/en/json.installation.php Co-authored-by: agj <[email protected]>
1 parent a0c563b commit 1d220e5

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

.github/workflows/build.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ jobs:
9898
- name: Build Tidy extension
9999
run: nix-build -A outputs.checks.${{ matrix.archs.arch }}.${{ steps.params.outputs.attr }}-tidy
100100

101+
- name: Build Decimal extension
102+
if: ${{ steps.params.outputs.major >= 7 }}
103+
run: nix-build -A outputs.checks.${{ matrix.archs.arch }}.${{ steps.params.outputs.attr }}-decimal
104+
101105
- name: Check that composer PHAR works
102106
run: nix-build -A outputs.checks.${{ matrix.archs.arch }}.${{ steps.params.outputs.attr }}-composer-phar
103107

checks.nix

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ let
5353
drv = { php, ... }: php.extensions.tidy;
5454
};
5555

56+
decimal = {
57+
description = "Build Decimal extension";
58+
enabled = { php, lib, ... }: lib.versionAtLeast php.version "7";
59+
drv = { php, ... }: php.extensions.decimal;
60+
};
61+
5662
composer-phar = {
5763
description = "Check that composer PHAR works";
5864
drv =

pkgs/package-overrides.nix

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,22 @@ in
104104
else
105105
prev.extensions.datadog_trace;
106106

107+
decimal =
108+
if lib.versionOlder prev.php.version "7.0" then
109+
throw "php.extensions.decimal requires PHP version >= 7.0"
110+
else if lib.versionOlder prev.php.version "8.0" then
111+
prev.extensions.decimal.overrideAttrs (attrs: {
112+
preConfigure = attrs.preConfigure or "" + linkInternalDeps [ final.extensions.json ];
113+
114+
env = mergeEnv attrs {
115+
NIX_CFLAGS_COMPILE = lib.optionals (lib.versionOlder prev.php.version "7.4") [
116+
"-Wno-incompatible-${lib.optionalString isClang "function-"}pointer-types"
117+
];
118+
};
119+
})
120+
else
121+
prev.extensions.decimal;
122+
107123
dom = prev.extensions.dom.overrideAttrs (attrs: {
108124
patches =
109125
let

0 commit comments

Comments
 (0)