Skip to content

Commit

Permalink
php7[01234].extension.decimal: Override decimal to allow use in PHP 7
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
agj and agj authored Feb 9, 2025
1 parent a0c563b commit 1d220e5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ jobs:
- name: Build Tidy extension
run: nix-build -A outputs.checks.${{ matrix.archs.arch }}.${{ steps.params.outputs.attr }}-tidy

- name: Build Decimal extension
if: ${{ steps.params.outputs.major >= 7 }}
run: nix-build -A outputs.checks.${{ matrix.archs.arch }}.${{ steps.params.outputs.attr }}-decimal

- name: Check that composer PHAR works
run: nix-build -A outputs.checks.${{ matrix.archs.arch }}.${{ steps.params.outputs.attr }}-composer-phar

Expand Down
6 changes: 6 additions & 0 deletions checks.nix
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ let
drv = { php, ... }: php.extensions.tidy;
};

decimal = {
description = "Build Decimal extension";
enabled = { php, lib, ... }: lib.versionAtLeast php.version "7";
drv = { php, ... }: php.extensions.decimal;
};

composer-phar = {
description = "Check that composer PHAR works";
drv =
Expand Down
16 changes: 16 additions & 0 deletions pkgs/package-overrides.nix
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,22 @@ in
else
prev.extensions.datadog_trace;

decimal =
if lib.versionOlder prev.php.version "7.0" then
throw "php.extensions.decimal requires PHP version >= 7.0"
else if lib.versionOlder prev.php.version "8.0" then
prev.extensions.decimal.overrideAttrs (attrs: {
preConfigure = attrs.preConfigure or "" + linkInternalDeps [ final.extensions.json ];

env = mergeEnv attrs {
NIX_CFLAGS_COMPILE = lib.optionals (lib.versionOlder prev.php.version "7.4") [
"-Wno-incompatible-${lib.optionalString isClang "function-"}pointer-types"
];
};
})
else
prev.extensions.decimal;

dom = prev.extensions.dom.overrideAttrs (attrs: {
patches =
let
Expand Down

0 comments on commit 1d220e5

Please sign in to comment.