phpPackages.composer: bootstrap with php.buildComposerProject2 builder
This commit is contained in:
@@ -1,41 +1,20 @@
|
||||
{
|
||||
lib,
|
||||
stdenvNoCC,
|
||||
fetchFromGitHub,
|
||||
callPackage,
|
||||
php,
|
||||
unzip,
|
||||
_7zz,
|
||||
xz,
|
||||
gitMinimal,
|
||||
curl,
|
||||
cacert,
|
||||
makeBinaryWrapper,
|
||||
_7zz,
|
||||
curl,
|
||||
gitMinimal,
|
||||
unzip,
|
||||
xz,
|
||||
versionCheckHook,
|
||||
}:
|
||||
|
||||
/*
|
||||
XXX IMPORTANT
|
||||
|
||||
Make sure to check if the `vendorHash` of `buildComposerProject2` changes when updating!
|
||||
See https://github.com/NixOS/nixpkgs/issues/451395
|
||||
*/
|
||||
|
||||
stdenvNoCC.mkDerivation (finalAttrs: {
|
||||
php.buildComposerProject2 (finalAttrs: {
|
||||
pname = "composer";
|
||||
version = "2.9.2";
|
||||
|
||||
# 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-Rx8thXq/DsGK97BV5hRyIU2RrbJPm9u7hkwcZPqtfdY=";
|
||||
|
||||
composer = callPackage ../../../build-support/php/pkgs/composer-phar.nix {
|
||||
inherit (finalAttrs) version;
|
||||
inherit (finalAttrs.passthru) pharHash;
|
||||
};
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "composer";
|
||||
repo = "composer";
|
||||
@@ -43,67 +22,20 @@ stdenvNoCC.mkDerivation (finalAttrs: {
|
||||
hash = "sha256-Ke+QGcKPqm1wEVVYgUCL0K3nT+qmzWpRX6HcZnzdhgA=";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [ makeBinaryWrapper ];
|
||||
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-Fe/aCn77nVuUc1Bp2TCZHJxe5oh4fwWw9Lj4So89pmE=";
|
||||
# Bootstrapping Composer (source) with Composer (PHAR distribution).
|
||||
# Override the default `composer` attribute to prevent infinite recursion.
|
||||
composer = callPackage ../../../build-support/php/pkgs/composer-phar.nix {
|
||||
inherit (finalAttrs) version;
|
||||
inherit (finalAttrs.passthru) pharHash;
|
||||
};
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out
|
||||
cp -ar ${finalAttrs.vendor}/* $out/
|
||||
chmod +w $out/bin
|
||||
vendorHash = "sha256-cqELlLH7d5KR62uVn7VtpQhVjkhXZkclXfc5d8RAG5Y=";
|
||||
|
||||
postInstall = ''
|
||||
wrapProgram $out/bin/composer \
|
||||
--prefix PATH : ${
|
||||
lib.makeBinPath [
|
||||
@@ -114,14 +46,18 @@ stdenvNoCC.mkDerivation (finalAttrs: {
|
||||
xz
|
||||
]
|
||||
}
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
doInstallCheck = true;
|
||||
nativeInstallCheckInputs = [ versionCheckHook ];
|
||||
versionCheckProgramArg = "--version";
|
||||
|
||||
# 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-Rx8thXq/DsGK97BV5hRyIU2RrbJPm9u7hkwcZPqtfdY=";
|
||||
|
||||
meta = {
|
||||
changelog = "https://github.com/composer/composer/releases/tag/${finalAttrs.version}";
|
||||
description = "Dependency Manager for PHP";
|
||||
|
||||
Reference in New Issue
Block a user