mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-01-10 15:04:44 +00:00
70 lines
1.9 KiB
Bash
70 lines
1.9 KiB
Bash
declare composerLock
|
|
declare version
|
|
declare composerNoDev
|
|
declare composerNoPlugins
|
|
declare composerNoScripts
|
|
|
|
preConfigureHooks+=(composerRepositoryConfigureHook)
|
|
preBuildHooks+=(composerRepositoryBuildHook)
|
|
preCheckHooks+=(composerRepositoryCheckHook)
|
|
preInstallHooks+=(composerRepositoryInstallHook)
|
|
|
|
composerRepositoryConfigureHook() {
|
|
echo "Executing composerRepositoryConfigureHook"
|
|
|
|
if [[ -e "$composerLock" ]]; then
|
|
cp $composerLock composer.lock
|
|
fi
|
|
|
|
if [[ ! -f "composer.lock" ]]; then
|
|
echo "No composer.lock file found, consider adding one to your repository to ensure reproducible builds."
|
|
composer \
|
|
--no-ansi \
|
|
--no-install \
|
|
--no-interaction \
|
|
${composerNoDev:+--no-dev} \
|
|
${composerNoPlugins:+--no-plugins} \
|
|
${composerNoScripts:+--no-scripts} \
|
|
update
|
|
echo "Using an autogenerated composer.lock file."
|
|
fi
|
|
|
|
echo "Finished composerRepositoryConfigureHook"
|
|
}
|
|
|
|
composerRepositoryBuildHook() {
|
|
echo "Executing composerRepositoryBuildHook"
|
|
|
|
mkdir -p repository
|
|
|
|
# Build the local composer repository
|
|
# The command 'build-local-repo' is provided by the Composer plugin
|
|
# nix-community/composer-local-repo-plugin.
|
|
COMPOSER_CACHE_DIR=/dev/null \
|
|
composer-local-repo-plugin --no-ansi build-local-repo ${composerNoDev:+--no-dev} -r repository
|
|
|
|
echo "Finished composerRepositoryBuildHook"
|
|
}
|
|
|
|
composerRepositoryCheckHook() {
|
|
echo "Executing composerRepositoryCheckHook"
|
|
|
|
composer validate --no-ansi --no-interaction
|
|
|
|
echo "Finished composerRepositoryCheckHook"
|
|
}
|
|
|
|
composerRepositoryInstallHook() {
|
|
echo "Executing composerRepositoryInstallHook"
|
|
|
|
mkdir -p $out
|
|
|
|
cp -ar repository/. $out/
|
|
|
|
# Copy the composer.lock files to the output directory, in case it has been
|
|
# autogenerated.
|
|
cp composer.lock $out/
|
|
|
|
echo "Finished composerRepositoryInstallHook"
|
|
}
|