depot/third_party/nixpkgs/pkgs/development/php-packages/composer/default.nix
Default email fa5436e0a7 Project import generated by Copybara.
GitOrigin-RevId: e8057b67ebf307f01bdcc8fba94d94f75039d1f6
2024-06-05 17:53:02 +02:00

121 lines
2.5 KiB
Nix

{
lib,
stdenvNoCC,
fetchFromGitHub,
callPackage,
php,
unzip,
_7zz,
xz,
git,
curl,
cacert,
makeBinaryWrapper,
}:
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
# package.
passthru.pharHash = "sha256-KdyaGe8zU12wYbMRgLKoM6fPjSz0FFszovg1BId7ugg=";
composer = callPackage ../../../build-support/php/pkgs/composer-phar.nix {
inherit (finalAttrs) version;
inherit (finalAttrs.passthru) pharHash;
};
src = fetchFromGitHub {
owner = "composer";
repo = "composer";
rev = finalAttrs.version;
hash = "sha256-LZwg3PR3zl07Nb6MS8oKkRfjLgqtT/c4sfUOzWE4S+U=";
};
nativeBuildInputs = [ makeBinaryWrapper ];
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
curl
git
unzip
xz
]
}
runHook postInstall
'';
meta = {
changelog = "https://github.com/composer/composer/releases/tag/${finalAttrs.version}";
description = "Dependency Manager for PHP";
homepage = "https://getcomposer.org/";
license = lib.licenses.mit;
mainProgram = "composer";
maintainers = lib.teams.php.members;
};
})