2024-01-02 11:29:13 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, buildGoModule
|
|
|
|
, fetchFromGitHub
|
|
|
|
, php
|
2024-02-07 01:22:34 +00:00
|
|
|
, brotli
|
2024-01-02 11:29:13 +00:00
|
|
|
, testers
|
|
|
|
, frankenphp
|
|
|
|
, darwin
|
2024-05-15 15:35:15 +00:00
|
|
|
, libiconv
|
2024-01-02 11:29:13 +00:00
|
|
|
, pkg-config
|
|
|
|
, makeBinaryWrapper
|
|
|
|
, runCommand
|
|
|
|
, writeText
|
|
|
|
}:
|
|
|
|
|
|
|
|
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";
|
|
|
|
pieBuild = stdenv.hostPlatform.isMusl;
|
|
|
|
in buildGoModule rec {
|
|
|
|
pname = "frankenphp";
|
2024-05-15 15:35:15 +00:00
|
|
|
version = "1.1.5";
|
2024-01-02 11:29:13 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "dunglas";
|
|
|
|
repo = "frankenphp";
|
|
|
|
rev = "v${version}";
|
2024-05-15 15:35:15 +00:00
|
|
|
hash = "sha256-W+9p/9qT7v1jq6m/gRgfw4AmnPRZVY3UixXaypUVn4E=";
|
2024-01-02 11:29:13 +00:00
|
|
|
};
|
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
sourceRoot = "${src.name}/caddy";
|
2024-01-02 11:29:13 +00:00
|
|
|
|
|
|
|
# frankenphp requires C code that would be removed with `go mod tidy`
|
|
|
|
# https://github.com/golang/go/issues/26366
|
|
|
|
proxyVendor = true;
|
2024-05-15 15:35:15 +00:00
|
|
|
vendorHash = "sha256-eNW03oBaON2X5X2ZbM3Ly5T+bJzSDhEYajY5LaZhwdQ=";
|
2024-01-02 11:29:13 +00:00
|
|
|
|
2024-02-07 01:22:34 +00:00
|
|
|
buildInputs = [ phpUnwrapped brotli ] ++ phpUnwrapped.buildInputs;
|
2024-01-02 11:29:13 +00:00
|
|
|
nativeBuildInputs = [ makeBinaryWrapper ] ++ lib.optionals stdenv.isDarwin [ pkg-config darwin.cctools darwin.autoSignDarwinBinariesHook ];
|
|
|
|
|
|
|
|
subPackages = [ "frankenphp" ];
|
|
|
|
|
|
|
|
tags = [ "cgo" "netgo" "ousergo" "static_build" ];
|
|
|
|
|
|
|
|
ldflags = [
|
|
|
|
"-s"
|
|
|
|
"-w"
|
|
|
|
"-X 'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP ${version} PHP ${phpUnwrapped.version} Caddy'"
|
|
|
|
# pie mode is only available with pkgsMusl, it also automaticaly add -buildmode=pie to $GOFLAGS
|
|
|
|
] ++ (lib.optional pieBuild [ "-static-pie" ]);
|
|
|
|
|
|
|
|
preBuild = ''
|
|
|
|
export CGO_CFLAGS="$(${phpConfig} --includes)"
|
|
|
|
export CGO_LDFLAGS="-DFRANKENPHP_VERSION=${version} \
|
|
|
|
$(${phpConfig} --ldflags) \
|
|
|
|
$(${phpConfig} --libs)"
|
|
|
|
'' + lib.optionalString stdenv.isDarwin ''
|
|
|
|
# replace hard-code homebrew path
|
|
|
|
substituteInPlace ../frankenphp.go \
|
2024-05-15 15:35:15 +00:00
|
|
|
--replace "-L/opt/homebrew/opt/libiconv/lib" "-L${libiconv}/lib"
|
2024-01-02 11:29:13 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
preFixup = ''
|
|
|
|
mkdir -p $out/lib
|
|
|
|
ln -s "${phpEmbedWithZts}/lib/php.ini" "$out/lib/frankenphp.ini"
|
|
|
|
|
|
|
|
wrapProgram $out/bin/frankenphp --set-default PHP_INI_SCAN_DIR $out/lib
|
|
|
|
'';
|
|
|
|
|
|
|
|
doCheck = false;
|
|
|
|
|
|
|
|
passthru = {
|
|
|
|
php = phpEmbedWithZts;
|
|
|
|
tests = {
|
|
|
|
# TODO: real NixOS test with Symfony application
|
|
|
|
version = testers.testVersion {
|
|
|
|
inherit version;
|
|
|
|
package = frankenphp;
|
|
|
|
command = "frankenphp version";
|
|
|
|
};
|
|
|
|
phpinfo = runCommand "php-cli-phpinfo" {
|
|
|
|
phpScript = writeText "phpinfo.php" ''
|
|
|
|
<?php phpinfo();
|
|
|
|
'';
|
|
|
|
} ''
|
|
|
|
${lib.getExe frankenphp} php-cli $phpScript > $out
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
changelog = "https://github.com/dunglas/frankenphp/releases/tag/v${version}";
|
|
|
|
description = "The modern PHP app server";
|
|
|
|
homepage = "https://github.com/dunglas/frankenphp";
|
|
|
|
license = licenses.mit;
|
|
|
|
mainProgram = "frankenphp";
|
|
|
|
maintainers = with maintainers; [ gaelreyrol shyim ];
|
|
|
|
platforms = platforms.linux ++ platforms.darwin;
|
|
|
|
};
|
|
|
|
}
|