frankenphp: add darwin support

This commit is contained in:
Soner Sayakci 2023-12-02 15:16:29 +01:00
parent 7da500d7cb
commit 21e686eaec
No known key found for this signature in database

View File

@ -5,6 +5,8 @@
, php
, testers
, frankenphp
, darwin
, pkg-config
, runCommand
, writeText
}:
@ -13,6 +15,9 @@ let
phpEmbedWithZts = php.override {
embedSupport = true;
ztsSupport = true;
staticSupport = stdenv.isDarwin;
zendSignalsSupport = false;
zendMaxExecutionTimersSupport = stdenv.isLinux;
};
phpUnwrapped = phpEmbedWithZts.unwrapped;
phpConfig = "${phpUnwrapped.dev}/bin/php-config";
@ -36,6 +41,7 @@ in buildGoModule rec {
vendorHash = "sha256-Lgj/pFtSQIgjrycajJ1zNY3ytvArmuk0E3IjsAzsNdM=";
buildInputs = [ phpUnwrapped ] ++ phpUnwrapped.buildInputs;
nativeBuildInputs = lib.optionals stdenv.isDarwin [ pkg-config darwin.cctools darwin.autoSignDarwinBinariesHook ];
subPackages = [ "frankenphp" ];
@ -52,7 +58,15 @@ in buildGoModule rec {
export CGO_CFLAGS="$(${phpConfig} --includes)"
export CGO_LDFLAGS="-DFRANKENPHP_VERSION=${version} \
$(${phpConfig} --ldflags) \
-Wl,--start-group $(${phpConfig} --libs) -Wl,--end-group"
$(${phpConfig} --libs)"
'' + lib.optionalString stdenv.isDarwin ''
# replace hard-code homebrew path
substituteInPlace ../frankenphp.go \
--replace "-L/opt/homebrew/opt/libiconv/lib" "-L${darwin.libiconv}/lib"
# remove when https://github.com/dunglas/frankenphp/pull/331 is merged and released
substituteInPlace ../frankenphp.go \
--replace "darwin pkg-config: libxml-2.0 sqlite3" "darwin pkg-config: libxml-2.0"
'';
doCheck = false;
@ -83,6 +97,6 @@ in buildGoModule rec {
license = licenses.mit;
mainProgram = "frankenphp";
maintainers = with maintainers; [ gaelreyrol ];
platforms = platforms.linux;
platforms = platforms.linux ++ platforms.darwin;
};
}