Merge pull request #312231 from drupol/build-support/php/init-composer-with-plugin

build-support/php: init new builder `php.buildComposerWithPlugin`, refactor `php.packages.composer`, etc
This commit is contained in:
Pol Dellaiera 2024-05-23 12:03:42 +02:00 committed by GitHub
commit a18047b6ad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
18 changed files with 1070 additions and 142 deletions

View File

@ -2,6 +2,7 @@
{
v1 = {
buildComposerProject = callPackage ./v1/build-composer-project.nix { };
buildComposerWithPlugin = callPackage ./v1/build-composer-with-plugin.nix { };
mkComposerRepository = callPackage ./v1/build-composer-repository.nix { };
composerHooks = callPackages ./v1/hooks { };
};

View File

@ -1,5 +1,4 @@
{
callPackage,
nix-update-script,
stdenvNoCC,
lib,
@ -12,8 +11,7 @@ let
let
phpDrv = finalAttrs.php or php;
composer = finalAttrs.composer or phpDrv.packages.composer;
composer-local-repo-plugin = callPackage ../../pkgs/composer-local-repo-plugin.nix { };
composer = finalAttrs.composer or phpDrv.packages.composer-local-repo-plugin;
in
{
composerLock = previousAttrs.composerLock or null;
@ -24,7 +22,6 @@ let
nativeBuildInputs = (previousAttrs.nativeBuildInputs or [ ]) ++ [
composer
composer-local-repo-plugin
phpDrv
phpDrv.composerHooks.composerInstallHook
];
@ -74,7 +71,7 @@ let
composerRepository =
previousAttrs.composerRepository or (phpDrv.mkComposerRepository {
inherit composer composer-local-repo-plugin;
inherit composer;
inherit (finalAttrs)
patches
pname

View File

@ -1,5 +1,4 @@
{
callPackage,
stdenvNoCC,
lib,
php,
@ -23,8 +22,7 @@ let
let
phpDrv = finalAttrs.php or php;
composer = finalAttrs.composer or phpDrv.packages.composer;
composer-local-repo-plugin = callPackage ../../pkgs/composer-local-repo-plugin.nix { };
composer = finalAttrs.composer or phpDrv.packages.composer-local-repo-plugin;
in
assert (lib.assertMsg (previousAttrs ? src) "mkComposerRepository expects src argument.");
assert (
@ -58,7 +56,6 @@ let
nativeBuildInputs = (previousAttrs.nativeBuildInputs or [ ]) ++ [
composer
composer-local-repo-plugin
phpDrv
phpDrv.composerHooks.composerRepositoryHook
];

View File

@ -0,0 +1,161 @@
{
stdenvNoCC,
writeText,
lib,
makeBinaryWrapper,
php,
cacert,
nix-update-script,
}:
let
composerJsonBuilder =
pluginName: pluginVersion:
writeText "composer.json" (
builtins.toJSON {
name = "nix/plugin";
description = "Nix Composer plugin";
license = "MIT";
require = {
"${pluginName}" = "${pluginVersion}";
};
config = {
"allow-plugins" = {
"${pluginName}" = true;
};
};
repositories = [
{
type = "path";
url = "./src";
options = {
versions = {
"${pluginName}" = "${pluginVersion}";
};
};
}
];
}
);
buildComposerWithPluginOverride =
finalAttrs: previousAttrs:
let
phpDrv = finalAttrs.php or php;
composer = finalAttrs.composer or phpDrv.packages.composer;
in
{
composerLock = previousAttrs.composerLock or null;
composerNoDev = previousAttrs.composerNoDev or true;
composerNoPlugins = previousAttrs.composerNoPlugins or true;
composerNoScripts = previousAttrs.composerNoScripts or true;
composerStrictValidation = previousAttrs.composerStrictValidation or true;
composerGlobal = true;
nativeBuildInputs = (previousAttrs.nativeBuildInputs or [ ]) ++ [
composer
phpDrv
makeBinaryWrapper
];
buildInputs = (previousAttrs.buildInputs or [ ]) ++ [ phpDrv ];
patches = previousAttrs.patches or [ ];
strictDeps = previousAttrs.strictDeps or true;
# Should we keep these empty phases?
configurePhase =
previousAttrs.configurePhase or ''
runHook preConfigure
runHook postConfigure
'';
buildPhase =
previousAttrs.buildPhase or ''
runHook preBuild
runHook postBuild
'';
doCheck = previousAttrs.doCheck or true;
checkPhase =
previousAttrs.checkPhase or ''
runHook preCheck
runHook postCheck
'';
installPhase =
previousAttrs.installPhase or ''
runHook preInstall
makeWrapper ${lib.getExe composer} $out/bin/composer \
--prefix COMPOSER_HOME : ${finalAttrs.vendor}
runHook postInstall
'';
doInstallCheck = previousAttrs.doInstallCheck or false;
installCheckPhase =
previousAttrs.installCheckPhase or ''
runHook preInstallCheck
composer global show ${finalAttrs.pname}
runHook postInstallCheck
'';
vendor = previousAttrs.vendor or stdenvNoCC.mkDerivation {
pname = "${finalAttrs.pname}-vendor";
pluginName = finalAttrs.pname;
inherit (finalAttrs) version src;
composerLock = previousAttrs.composerLock or null;
composerNoDev = previousAttrs.composerNoDev or true;
composerNoPlugins = previousAttrs.composerNoPlugins or true;
composerNoScripts = previousAttrs.composerNoScripts or true;
composerStrictValidation = previousAttrs.composerStrictValidation or true;
composerGlobal = true;
composerJson = composerJsonBuilder finalAttrs.pname finalAttrs.version;
nativeBuildInputs = [
cacert
composer
phpDrv.composerHooks.composerWithPluginVendorHook
];
dontPatchShebangs = true;
doCheck = true;
doInstallCheck = true;
env = {
COMPOSER_CACHE_DIR = "/dev/null";
COMPOSER_HTACCESS_PROTECT = "0";
};
outputHashMode = "recursive";
outputHashAlgo = "sha256";
outputHash = finalAttrs.vendorHash;
};
# Projects providing a lockfile from upstream can be automatically updated.
passthru = previousAttrs.passthru or { } // {
updateScript =
previousAttrs.passthru.updateScript
or (if finalAttrs.vendor.composerLock == null then nix-update-script { } else null);
};
env = {
COMPOSER_CACHE_DIR = "/dev/null";
COMPOSER_DISABLE_NETWORK = "1";
COMPOSER_MIRROR_PATH_REPOS = "1";
};
meta = previousAttrs.meta or composer.meta;
};
in
args: (stdenvNoCC.mkDerivation args).overrideAttrs buildComposerWithPluginOverride

View File

@ -83,7 +83,7 @@ composerInstallBuildHook() {
# Since this file cannot be generated in the composer-repository-hook.sh
# because the file contains hardcoded nix store paths, we generate it here.
composer-local-repo-plugin --no-ansi build-local-repo-lock -m "${composerRepository}" .
composer build-local-repo-lock -m "${composerRepository}" .
echo "Finished composerInstallBuildHook"
}

View File

@ -63,7 +63,7 @@ composerRepositoryBuildHook() {
# Build the local composer repository
# The command 'build-local-repo' is provided by the Composer plugin
# nix-community/composer-local-repo-plugin.
composer-local-repo-plugin --no-ansi build-local-repo-lock ${composerNoDev:+--no-dev} -r repository
composer build-local-repo-lock ${composerNoDev:+--no-dev} -r repository
echo "Finished composerRepositoryBuildHook"
}

View File

@ -0,0 +1,93 @@
declare composerLock
declare version
declare composerNoDev
declare composerNoPlugins
declare composerNoScripts
declare composerStrictValidation
preConfigureHooks+=(composerWithPluginConfigureHook)
preBuildHooks+=(composerWithPluginBuildHook)
preCheckHooks+=(composerWithPluginCheckHook)
preInstallHooks+=(composerWithPluginInstallHook)
preInstallCheckHooks+=(composerWithPluginInstallCheckHook)
source @phpScriptUtils@
composerWithPluginConfigureHook() {
echo "Executing composerWithPluginConfigureHook"
mkdir -p $out
export COMPOSER_HOME=$out
if [[ -e "$composerLock" ]]; then
cp $composerLock $out/composer.lock
fi
cp $composerJson $out/composer.json
cp -ar $src $out/src
if [[ ! -f "$out/composer.lock" ]]; then
setComposeRootVersion
composer \
global \
--no-install \
--no-interaction \
--no-progress \
${composerNoDev:+--no-dev} \
${composerNoPlugins:+--no-plugins} \
${composerNoScripts:+--no-scripts} \
update
echo
echo -e "\e[31mERROR: No composer.lock found\e[0m"
echo
echo -e '\e[31mNo composer.lock file found, consider adding one to your repository to ensure reproducible builds.\e[0m'
echo -e "\e[31mIn the meantime, a composer.lock file has been generated for you in $out/composer.lock\e[0m"
echo
echo -e '\e[31mTo fix the issue:\e[0m'
echo -e "\e[31m1. Copy the composer.lock file from $out/composer.lock to the project's source:\e[0m"
echo -e "\e[31m cp $out/composer.lock <path>\e[0m"
echo -e '\e[31m2. Add the composerLock attribute, pointing to the copied composer.lock file:\e[0m'
echo -e '\e[31m composerLock = ./composer.lock;\e[0m'
echo
exit 1
fi
echo "Finished composerWithPluginConfigureHook"
}
composerWithPluginBuildHook() {
echo "Executing composerWithPluginBuildHook"
echo "Finished composerWithPluginBuildHook"
}
composerWithPluginCheckHook() {
echo "Executing composerWithPluginCheckHook"
checkComposerValidate
echo "Finished composerWithPluginCheckHook"
}
composerWithPluginInstallHook() {
echo "Executing composerWithPluginInstallHook"
composer \
global \
--no-interaction \
--no-progress \
${composerNoDev:+--no-dev} \
${composerNoPlugins:+--no-plugins} \
${composerNoScripts:+--no-scripts} \
install
echo "Finished composerWithPluginInstallHook"
}
composerWithPluginInstallCheckHook() {
composer global show $pluginName
}

View File

@ -42,4 +42,19 @@ in
phpScriptUtils = lib.getExe php-script-utils;
};
} ./composer-install-hook.sh;
composerWithPluginVendorHook = makeSetupHook {
name = "composer-with-plugin-vendor-hook.sh";
propagatedBuildInputs = [
jq
moreutils
cacert
];
substitutions = {
# Specify the stdenv's `diff` by abspath to ensure that the user's build
# inputs do not cause us to find the wrong `diff`.
cmp = "${lib.getBin buildPackages.diffutils}/bin/cmp";
phpScriptUtils = lib.getExe php-script-utils;
};
} ./composer-with-plugin-vendor-hook.sh;
}

View File

@ -1,5 +1,6 @@
declare version
declare composerStrictValidation
declare composerGlobal
setComposeRootVersion() {
set +e # Disable exit on error
@ -13,7 +14,16 @@ setComposeRootVersion() {
}
checkComposerValidate() {
if ! composer validate --strict --no-ansi --no-interaction --quiet --no-check-all --no-check-lock; then
setComposeRootVersion
if [ "1" == "${composerGlobal-}" ]; then
global="global";
else
global="";
fi
command="composer ${global} validate --strict --quiet --no-interaction --no-check-all --no-check-lock"
if ! $command; then
if [ "1" == "${composerStrictValidation-}" ]; then
echo
echo -e "\e[31mERROR: composer files validation failed\e[0m"
@ -42,7 +52,8 @@ checkComposerValidate() {
fi
fi
if ! composer validate --strict --no-ansi --no-interaction --quiet --no-check-all --check-lock; then
command="composer ${global} validate --strict --no-ansi --no-interaction --quiet --no-check-all --check-lock"
if ! $command; then
if [ "1" == "${composerStrictValidation-}" ]; then
echo
echo -e "\e[31mERROR: composer files validation failed\e[0m"

View File

@ -1,116 +0,0 @@
{
php,
callPackage,
stdenvNoCC,
lib,
fetchFromGitHub,
makeBinaryWrapper,
}:
let
composer = callPackage ./composer-phar.nix { inherit (php.packages.composer) version pharHash; };
composerKeys = stdenvNoCC.mkDerivation (finalComposerKeysAttrs: {
pname = "composer-keys";
version = "fa5a62092f33e094073fbda23bbfc7188df3cbc5";
src = fetchFromGitHub {
owner = "composer";
repo = "composer.github.io";
rev = "${finalComposerKeysAttrs.version}";
hash = "sha256-3Sfn71LDG1jHwuEIU8iEnV3k6D6QTX7KVIKVaNSuCVE=";
};
installPhase = ''
runHook preInstall
mkdir -p $out
install releases.pub $out/keys.tags.pub
install snapshots.pub $out/keys.dev.pub
runHook postInstall
'';
});
in
stdenvNoCC.mkDerivation (finalAttrs: {
pname = "composer-local-repo-plugin";
version = "1.1.0";
src = fetchFromGitHub {
owner = "nix-community";
repo = "composer-local-repo-plugin";
rev = finalAttrs.version;
hash = "sha256-edbn07r/Uc1g0qOuVBZBs6N1bMN5kIfA1b4FCufdw5M=";
};
env = {
COMPOSER_CACHE_DIR = "/dev/null";
COMPOSER_MIRROR_PATH_REPOS = "1";
COMPOSER_HTACCESS_PROTECT = "0";
COMPOSER_DISABLE_NETWORK = "1";
};
nativeBuildInputs = [ makeBinaryWrapper ];
buildInputs = [ composer ];
configurePhase = ''
runHook preConfigure
export COMPOSER_HOME=${placeholder "out"}
runHook postConfigure
'';
buildPhase = ''
runHook preBuild
# Configure composer globally
composer global init --quiet --no-interaction --no-ansi \
--name="nixos/composer" \
--homepage "https://nixos.org/" \
--description "Composer with nix-community/composer-local-repo-plugin" \
--license "MIT"
composer global config --quiet minimum-stability dev
composer global config --quiet prefer-stable true
composer global config --quiet apcu-autoloader false
composer global config --quiet allow-plugins.nix-community/composer-local-repo-plugin true
composer global config --quiet repo.packagist false
composer global config --quiet repo.plugin path $src
# Install the local repository plugin
composer global require --quiet --no-ansi --no-interaction nix-community/composer-local-repo-plugin
runHook postBuild
'';
checkPhase = ''
runHook preCheck
composer global validate --no-ansi
composer global show --no-ansi nix-community/composer-local-repo-plugin
runHook postCheck
'';
installPhase = ''
runHook preInstall
mkdir -p $out
cp -ar ${composerKeys}/* $out/
makeWrapper ${composer}/bin/composer $out/bin/composer-local-repo-plugin \
--prefix COMPOSER_HOME : $out
runHook postInstall
'';
meta = {
description = "Composer local repo plugin for Composer";
homepage = "https://github.com/nix-community/composer-local-repo-plugin";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ drupol ];
platforms = lib.platforms.all;
};
})

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

@ -164,7 +164,7 @@ let
nixos = lib.recurseIntoAttrs nixosTests."php${lib.strings.replaceStrings [ "." ] [ "" ] (lib.versions.majorMinor php.version)}";
package = tests.php;
};
inherit (php-packages) extensions buildPecl mkComposerRepository buildComposerProject composerHooks mkExtension;
inherit (php-packages) extensions buildPecl mkComposerRepository buildComposerProject buildComposerWithPlugin composerHooks mkExtension;
packages = php-packages.tools;
meta = php.meta // {
outputsToInstall = [ "out" ];

View File

@ -0,0 +1,72 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "04664aa86ba468bc6c83825839823dd7",
"packages": [
{
"name": "nix-community/composer-local-repo-plugin",
"version": "1.1.0",
"dist": {
"type": "path",
"url": "./src",
"reference": "56bd0f1fb990aa295ca43fc23141b7147a3b5490"
},
"require": {
"composer-plugin-api": "^2",
"php": ">= 7.2"
},
"require-dev": {
"composer/composer": "^2.6 || ^2.7",
"phpunit/phpunit": "^8"
},
"type": "composer-plugin",
"extra": {
"class": "NixCommunity\\ComposerLocalRepoPlugin\\Plugin"
},
"autoload": {
"psr-4": {
"NixCommunity\\ComposerLocalRepoPlugin\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"test\\NixCommunity\\ComposerLocalRepoPlugin\\": "test"
}
},
"scripts": {
"changelog-unreleased": [
"auto-changelog -c .auto-changelog -u"
],
"changelog-version": [
"auto-changelog -c .auto-changelog -v"
]
},
"license": [
"MIT"
],
"description": "A plugin for Composer which provides a command to create local Composer repository for your projects.",
"homepage": "https://github.com/nix-community/composer-local-repo-plugin",
"funding": [
{
"type": "github",
"url": "https://github.com/drupol"
}
],
"transport-options": {
"relative": true
}
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
"platform-dev": [],
"plugin-api-version": "2.6.0"
}

View File

@ -0,0 +1,33 @@
{
lib,
fetchFromGitHub,
php,
}:
let
version = "1.1.0";
in
php.buildComposerWithPlugin {
pname = "nix-community/composer-local-repo-plugin";
inherit version;
src = fetchFromGitHub {
owner = "nix-community";
repo = "composer-local-repo-plugin";
rev = version;
hash = "sha256-edbn07r/Uc1g0qOuVBZBs6N1bMN5kIfA1b4FCufdw5M=";
};
composerLock = ./composer.lock;
vendorHash = "sha256-SL3HiYTVaUwcEfnRO932MWgOP1VRkxTl3lxLbW0qiTY=";
meta = {
changelog = "https://github.com/nix-community/composer-local-repo-plugin/releases/tag/${version}";
description = "Composer plugin that facilitates the creation of a local composer type repository";
homepage = "https://github.com/nix-community/composer-local-repo-plugin";
license = lib.licenses.mit;
mainProgram = "composer";
maintainers = with lib.maintainers; [ drupol ];
platforms = lib.platforms.all;
};
}

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}";

View File

@ -0,0 +1,571 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "c949500f008befd2980bd7f80454c43b",
"packages": [
{
"name": "composer/spdx-licenses",
"version": "1.5.8",
"source": {
"type": "git",
"url": "https://github.com/composer/spdx-licenses.git",
"reference": "560bdcf8deb88ae5d611c80a2de8ea9d0358cc0a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/composer/spdx-licenses/zipball/560bdcf8deb88ae5d611c80a2de8ea9d0358cc0a",
"reference": "560bdcf8deb88ae5d611c80a2de8ea9d0358cc0a",
"shasum": ""
},
"require": {
"php": "^5.3.2 || ^7.0 || ^8.0"
},
"require-dev": {
"phpstan/phpstan": "^0.12.55",
"symfony/phpunit-bridge": "^4.2 || ^5"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "1.x-dev"
}
},
"autoload": {
"psr-4": {
"Composer\\Spdx\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nils Adermann",
"email": "naderman@naderman.de",
"homepage": "http://www.naderman.de"
},
{
"name": "Jordi Boggiano",
"email": "j.boggiano@seld.be",
"homepage": "http://seld.be"
},
{
"name": "Rob Bast",
"email": "rob.bast@gmail.com",
"homepage": "http://robbast.nl"
}
],
"description": "SPDX licenses list and validation library.",
"keywords": [
"license",
"spdx",
"validator"
],
"support": {
"irc": "ircs://irc.libera.chat:6697/composer",
"issues": "https://github.com/composer/spdx-licenses/issues",
"source": "https://github.com/composer/spdx-licenses/tree/1.5.8"
},
"funding": [
{
"url": "https://packagist.com",
"type": "custom"
},
{
"url": "https://github.com/composer",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/composer/composer",
"type": "tidelift"
}
],
"time": "2023-11-20T07:44:33+00:00"
},
{
"name": "cyclonedx/cyclonedx-library",
"version": "v3.3.1",
"source": {
"type": "git",
"url": "https://github.com/CycloneDX/cyclonedx-php-library.git",
"reference": "cad0f92b36c85f36b3d3c11ff96002af5f20cd10"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/CycloneDX/cyclonedx-php-library/zipball/cad0f92b36c85f36b3d3c11ff96002af5f20cd10",
"reference": "cad0f92b36c85f36b3d3c11ff96002af5f20cd10",
"shasum": ""
},
"require": {
"composer/spdx-licenses": "^1.5",
"ext-dom": "*",
"ext-json": "*",
"ext-libxml": "*",
"opis/json-schema": "^2.0",
"package-url/packageurl-php": "^1.0",
"php": "^8.1"
},
"require-dev": {
"ext-simplexml": "*",
"roave/security-advisories": "dev-latest"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.x-dev"
},
"composer-normalize": {
"indent-size": 4,
"indent-style": "space"
}
},
"autoload": {
"psr-4": {
"CycloneDX\\Core\\": "src/Core/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"Apache-2.0"
],
"authors": [
{
"name": "Jan Kowalleck",
"email": "jan.kowalleck@gmail.com",
"homepage": "https://github.com/jkowalleck"
}
],
"description": "Work with CycloneDX documents.",
"homepage": "https://github.com/CycloneDX/cyclonedx-php-library/#readme",
"keywords": [
"CycloneDX",
"HBOM",
"OBOM",
"SBOM",
"SaaSBOM",
"bill-of-materials",
"bom",
"models",
"normalizer",
"owasp",
"package-url",
"purl",
"serializer",
"software-bill-of-materials",
"spdx",
"validator",
"vdr",
"vex"
],
"support": {
"docs": "https://cyclonedx-php-library.readthedocs.io",
"issues": "https://github.com/CycloneDX/cyclonedx-php-library/issues",
"source": "https://github.com/CycloneDX/cyclonedx-php-library/"
},
"funding": [
{
"url": "https://owasp.org/donate/?reponame=www-project-cyclonedx&title=OWASP+CycloneDX",
"type": "other"
}
],
"time": "2024-05-06T13:34:55+00:00"
},
{
"name": "cyclonedx/cyclonedx-php-composer",
"version": "5.2.0",
"dist": {
"type": "path",
"url": "./src",
"reference": "88ae6a60b882d72668d409b0d4fcc9bfa0c66259"
},
"require": {
"composer-plugin-api": "^2.3",
"cyclonedx/cyclonedx-library": "^3.3",
"package-url/packageurl-php": "^1.0",
"php": "^8.1"
},
"require-dev": {
"composer/composer": "^2.3.0",
"roave/security-advisories": "dev-latest"
},
"type": "composer-plugin",
"extra": {
"branch-alias": {
"dev-master": "4.x-dev"
},
"class": "CycloneDX\\Composer\\Plugin",
"composer-normalize": {
"indent-size": 4,
"indent-style": "space"
}
},
"autoload": {
"psr-4": {
"CycloneDX\\Composer\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"CycloneDX\\Tests\\": "tests/"
}
},
"scripts": {
"clean": [
"rm -rf reports",
"@php tools/psalm/vendor/vimeo/psalm/psalm --clear-cache",
"@php tools/psalm/vendor/vimeo/psalm/psalm --clear-global-cache",
"rm -rf .*.cache",
"rm -rf .tmp"
],
"cs-fix": [
"@php tools/php-cs-fixer/vendor/friendsofphp/php-cs-fixer/php-cs-fixer fix --diff"
],
"dev-setup": [
"@composer -d tools/composer-normalize update",
"@composer -d tools/composer-require-checker update",
"@composer -d tools/composer-unused update",
"@composer -d tools/php-cs-fixer update",
"@composer -d tools/psalm update",
"@composer -d tools/phpunit update",
"@composer update"
],
"normalize": [
"@composer -d tools/composer-normalize normalize --diff $PWD/composer.json"
],
"test": [
"@composer validate",
"@test:psalm",
"@test:phpunit",
"@test:cs-fixer",
"@test:composer-unused",
"@test:composer-require-checker",
"@test:composer-normalize"
],
"test:composer-normalize": [
"@composer -d tools/composer-normalize normalize --dry-run $PWD/composer.json"
],
"test:composer-require-checker": [
"@putenv XDEBUG_MODE=off",
"@php tools/composer-require-checker/vendor/maglnet/composer-require-checker/bin/composer-require-checker check"
],
"test:composer-unused": [
"@php tools/composer-unused/vendor/icanhazstring/composer-unused/bin/composer-unused --excludeDir=tools"
],
"test:cs-fixer": [
"@php tools/php-cs-fixer/vendor/friendsofphp/php-cs-fixer/php-cs-fixer fix --dry-run --diff"
],
"test:phpunit": [
"@php -d zend.assertions=1 -d assert.exception=1 -d display_errors=On -d error_reporting=-1 -d log_errors_max_len=0 -d memory_limit=-1 tools/phpunit/vendor/phpunit/phpunit/phpunit"
],
"test:psalm": [
"@php tools/psalm/vendor/vimeo/psalm/psalm"
]
},
"license": [
"Apache-2.0"
],
"authors": [
{
"name": "Jan Kowalleck",
"email": "jan.kowalleck@gmail.com",
"homepage": "https://github.com/jkowalleck"
}
],
"description": "Creates CycloneDX Software Bill-of-Materials (SBOM) from PHP Composer projects",
"homepage": "https://github.com/CycloneDX/cyclonedx-php-composer/#readme",
"keywords": [
"BOM",
"CycloneDX",
"PURL",
"SBOM",
"SPDX",
"bill-of-materials",
"composer",
"package-url",
"software-bill-of-materials"
],
"support": {
"issues": "https://github.com/CycloneDX/cyclonedx-php-composer/issues",
"source": "https://github.com/CycloneDX/cyclonedx-php-composer/"
},
"funding": [
{
"type": "other",
"url": "https://owasp.org/donate/?reponame=www-project-cyclonedx&title=OWASP+CycloneDX"
}
],
"transport-options": {
"relative": true
}
},
{
"name": "opis/json-schema",
"version": "2.3.0",
"source": {
"type": "git",
"url": "https://github.com/opis/json-schema.git",
"reference": "c48df6d7089a45f01e1c82432348f2d5976f9bfb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/opis/json-schema/zipball/c48df6d7089a45f01e1c82432348f2d5976f9bfb",
"reference": "c48df6d7089a45f01e1c82432348f2d5976f9bfb",
"shasum": ""
},
"require": {
"ext-json": "*",
"opis/string": "^2.0",
"opis/uri": "^1.0",
"php": "^7.4 || ^8.0"
},
"require-dev": {
"ext-bcmath": "*",
"ext-intl": "*",
"phpunit/phpunit": "^9.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.x-dev"
}
},
"autoload": {
"psr-4": {
"Opis\\JsonSchema\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"Apache-2.0"
],
"authors": [
{
"name": "Sorin Sarca",
"email": "sarca_sorin@hotmail.com"
},
{
"name": "Marius Sarca",
"email": "marius.sarca@gmail.com"
}
],
"description": "Json Schema Validator for PHP",
"homepage": "https://opis.io/json-schema",
"keywords": [
"json",
"json-schema",
"schema",
"validation",
"validator"
],
"support": {
"issues": "https://github.com/opis/json-schema/issues",
"source": "https://github.com/opis/json-schema/tree/2.3.0"
},
"time": "2022-01-08T20:38:03+00:00"
},
{
"name": "opis/string",
"version": "2.0.1",
"source": {
"type": "git",
"url": "https://github.com/opis/string.git",
"reference": "9ebf1a1f873f502f6859d11210b25a4bf5d141e7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/opis/string/zipball/9ebf1a1f873f502f6859d11210b25a4bf5d141e7",
"reference": "9ebf1a1f873f502f6859d11210b25a4bf5d141e7",
"shasum": ""
},
"require": {
"ext-iconv": "*",
"ext-json": "*",
"php": "^7.4 || ^8.0"
},
"require-dev": {
"phpunit/phpunit": "^9.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.x-dev"
}
},
"autoload": {
"psr-4": {
"Opis\\String\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"Apache-2.0"
],
"authors": [
{
"name": "Marius Sarca",
"email": "marius.sarca@gmail.com"
},
{
"name": "Sorin Sarca",
"email": "sarca_sorin@hotmail.com"
}
],
"description": "Multibyte strings as objects",
"homepage": "https://opis.io/string",
"keywords": [
"multi-byte",
"opis",
"string",
"string manipulation",
"utf-8"
],
"support": {
"issues": "https://github.com/opis/string/issues",
"source": "https://github.com/opis/string/tree/2.0.1"
},
"time": "2022-01-14T15:42:23+00:00"
},
{
"name": "opis/uri",
"version": "1.1.0",
"source": {
"type": "git",
"url": "https://github.com/opis/uri.git",
"reference": "0f3ca49ab1a5e4a6681c286e0b2cc081b93a7d5a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/opis/uri/zipball/0f3ca49ab1a5e4a6681c286e0b2cc081b93a7d5a",
"reference": "0f3ca49ab1a5e4a6681c286e0b2cc081b93a7d5a",
"shasum": ""
},
"require": {
"opis/string": "^2.0",
"php": "^7.4 || ^8.0"
},
"require-dev": {
"phpunit/phpunit": "^9"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.x-dev"
}
},
"autoload": {
"psr-4": {
"Opis\\Uri\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"Apache-2.0"
],
"authors": [
{
"name": "Marius Sarca",
"email": "marius.sarca@gmail.com"
},
{
"name": "Sorin Sarca",
"email": "sarca_sorin@hotmail.com"
}
],
"description": "Build, parse and validate URIs and URI-templates",
"homepage": "https://opis.io",
"keywords": [
"URI Template",
"parse url",
"punycode",
"uri",
"uri components",
"url",
"validate uri"
],
"support": {
"issues": "https://github.com/opis/uri/issues",
"source": "https://github.com/opis/uri/tree/1.1.0"
},
"time": "2021-05-22T15:57:08+00:00"
},
{
"name": "package-url/packageurl-php",
"version": "1.1.2",
"source": {
"type": "git",
"url": "https://github.com/package-url/packageurl-php.git",
"reference": "32058ad61f0d8b457fa26e7860bbd8b903196d3f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/package-url/packageurl-php/zipball/32058ad61f0d8b457fa26e7860bbd8b903196d3f",
"reference": "32058ad61f0d8b457fa26e7860bbd8b903196d3f",
"shasum": ""
},
"require": {
"php": "^7.3 || ^8.0"
},
"require-dev": {
"ext-json": "*",
"phpunit/phpunit": "9.6.16",
"roave/security-advisories": "dev-latest"
},
"type": "library",
"extra": {
"composer-normalize": {
"indent-size": 4,
"indent-style": "space"
}
},
"autoload": {
"psr-4": {
"PackageUrl\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jan Kowalleck",
"email": "jan.kowalleck@gmail.com",
"homepage": "https://github.com/jkowalleck"
}
],
"description": "Builder and parser based on the package URL (purl) specification.",
"homepage": "https://github.com/package-url/packageurl-php#readme",
"keywords": [
"package",
"package-url",
"packageurl",
"purl",
"url"
],
"support": {
"issues": "https://github.com/package-url/packageurl-php/issues",
"source": "https://github.com/package-url/packageurl-php/tree/1.1.2"
},
"funding": [
{
"url": "https://github.com/sponsors/jkowalleck",
"type": "github"
}
],
"time": "2024-02-05T11:20:07+00:00"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
"platform-dev": [],
"plugin-api-version": "2.6.0"
}

View File

@ -0,0 +1,33 @@
{
lib,
fetchFromGitHub,
php,
}:
let
version = "5.2.0";
in
php.buildComposerWithPlugin {
pname = "cyclonedx/cyclonedx-php-composer";
inherit version;
src = fetchFromGitHub {
owner = "CycloneDX";
repo = "cyclonedx-php-composer";
rev = "v${version}";
hash = "sha256-0fb1QiuVJqcB7CAEyB0y60/O9iiibT06mccZYe52dFQ=";
};
composerLock = ./composer.lock;
vendorHash = "sha256-QPlHWXXksetNSsv3olmCtPA/VsFVPV09rYQEsPezZoE=";
meta = {
changelog = "https://github.com/CycloneDX/cyclonedx-php-composer/releases/tag/v${version}";
description = "Composer plugin that facilitates the creation of a CycloneDX Software Bill of Materials (SBOM) from PHP Composer projects";
homepage = "https://github.com/CycloneDX/cyclonedx-php-composer";
license = lib.licenses.asl20;
mainProgram = "composer";
maintainers = with lib.maintainers; [ drupol ];
platforms = lib.platforms.all;
};
}

View File

@ -57,7 +57,7 @@ in {
php = php.unwrapped;
};
inherit (builders.v1) buildComposerProject composerHooks mkComposerRepository;
inherit (builders.v1) buildComposerProject buildComposerWithPlugin composerHooks mkComposerRepository;
# Wrap mkDerivation to prepend pname with "php-" to make names consistent
# with how buildPecl does it and make the file easier to overview.
@ -191,6 +191,10 @@ in {
composer = callPackage ../development/php-packages/composer { };
composer-local-repo-plugin = callPackage ../development/php-packages/composer-local-repo-plugin { };
cyclonedx-php-composer = callPackage ../development/php-packages/cyclonedx-php-composer { };
deployer = callPackage ../development/php-packages/deployer { };
grumphp = callPackage ../development/php-packages/grumphp { };