php.packages.composer: do not use buildComposerProject

I decided to avoid the use of `buildComposerProject because it requires `composer-local-repo-plugin` which is going to be refactored.
This commit is contained in:
Pol Dellaiera 2024-05-16 16:44:22 +02:00
parent 6bad2e219e
commit 450e9396fd
No known key found for this signature in database
GPG Key ID: D476DFE9C67467CA
2 changed files with 67 additions and 11 deletions

View File

@ -1,6 +1,5 @@
{
_7zz,
cacert,
curl,
fetchurl,
git,
@ -37,7 +36,6 @@ stdenvNoCC.mkDerivation (finalAttrs: {
--prefix PATH : ${
lib.makeBinPath [
_7zz
cacert
curl
git
unzip

View File

@ -1,7 +1,8 @@
{
lib,
callPackage,
stdenvNoCC,
fetchFromGitHub,
callPackage,
php,
unzip,
_7zz,
@ -12,7 +13,10 @@
makeBinaryWrapper,
}:
php.buildComposerProject (finalAttrs: {
stdenvNoCC.mkDerivation (finalAttrs: {
pname = "composer";
version = "2.7.6";
# Hash used by ../../../build-support/php/pkgs/composer-phar.nix to
# use together with the version from this package to keep the
# bootstrap phar file up-to-date together with the end user composer
@ -24,9 +28,6 @@ php.buildComposerProject (finalAttrs: {
inherit (finalAttrs.passthru) pharHash;
};
pname = "composer";
version = "2.7.6";
src = fetchFromGitHub {
owner = "composer";
repo = "composer";
@ -36,21 +37,78 @@ php.buildComposerProject (finalAttrs: {
nativeBuildInputs = [ makeBinaryWrapper ];
postInstall = ''
buildInputs = [ php ];
vendor = stdenvNoCC.mkDerivation {
pname = "${finalAttrs.pname}-vendor";
inherit (finalAttrs) src version;
nativeBuildInputs = [
cacert
finalAttrs.composer
];
dontPatchShebangs = true;
doCheck = true;
buildPhase = ''
runHook preBuild
composer install --no-dev --no-interaction --no-progress --optimize-autoloader
runHook postBuild
'';
checkPhase = ''
runHook preCheck
composer validate
runHook postCheck
'';
installPhase = ''
runHook preInstall
cp -ar . $out/
runHook postInstall
'';
env = {
COMPOSER_CACHE_DIR = "/dev/null";
COMPOSER_DISABLE_NETWORK = "0";
COMPOSER_HTACCESS_PROTECT = "0";
COMPOSER_MIRROR_PATH_REPOS = "1";
COMPOSER_ROOT_VERSION = finalAttrs.version;
};
outputHashMode = "recursive";
outputHashAlgo = "sha256";
outputHash = "sha256-AyX57oV5Jf8U4B9tEl+b2Rnt/Igu7ockEap0wfN9b2Q=";
};
installPhase = ''
runHook preInstall
mkdir -p $out
cp -ar ${finalAttrs.vendor}/* $out/
chmod +w $out/bin
wrapProgram $out/bin/composer \
--prefix PATH : ${
lib.makeBinPath [
_7zz
cacert
curl
git
unzip
xz
]
}
'';
vendorHash = "sha256-dNNV9fTyGyRoGeDV/vBjn0aMgkaUMsrKQv5AOoiYokQ=";
runHook postInstall
'';
meta = {
changelog = "https://github.com/composer/composer/releases/tag/${finalAttrs.version}";