build-support/php: set COMPOSER_ROOT_VERSION
by default
This commit is contained in:
parent
2a34566b67
commit
f43fb4c110
4 changed files with 38 additions and 6 deletions
|
@ -9,6 +9,8 @@ preBuildHooks+=(composerInstallBuildHook)
|
||||||
preCheckHooks+=(composerInstallCheckHook)
|
preCheckHooks+=(composerInstallCheckHook)
|
||||||
preInstallHooks+=(composerInstallInstallHook)
|
preInstallHooks+=(composerInstallInstallHook)
|
||||||
|
|
||||||
|
source @phpScriptUtils@
|
||||||
|
|
||||||
composerInstallConfigureHook() {
|
composerInstallConfigureHook() {
|
||||||
echo "Executing composerInstallConfigureHook"
|
echo "Executing composerInstallConfigureHook"
|
||||||
|
|
||||||
|
@ -22,6 +24,8 @@ composerInstallConfigureHook() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -f "composer.lock" ]]; then
|
if [[ ! -f "composer.lock" ]]; then
|
||||||
|
setComposeRootVersion
|
||||||
|
|
||||||
composer \
|
composer \
|
||||||
--no-ansi \
|
--no-ansi \
|
||||||
--no-install \
|
--no-install \
|
||||||
|
@ -75,6 +79,8 @@ composerInstallConfigureHook() {
|
||||||
composerInstallBuildHook() {
|
composerInstallBuildHook() {
|
||||||
echo "Executing composerInstallBuildHook"
|
echo "Executing composerInstallBuildHook"
|
||||||
|
|
||||||
|
setComposeRootVersion
|
||||||
|
|
||||||
# Since this file cannot be generated in the composer-repository-hook.sh
|
# Since this file cannot be generated in the composer-repository-hook.sh
|
||||||
# because the file contains hardcoded nix store paths, we generate it here.
|
# because the file contains hardcoded nix store paths, we generate it here.
|
||||||
composer-local-repo-plugin --no-ansi build-local-repo -m "${composerRepository}" .
|
composer-local-repo-plugin --no-ansi build-local-repo -m "${composerRepository}" .
|
||||||
|
@ -90,7 +96,6 @@ composerInstallBuildHook() {
|
||||||
|
|
||||||
# Since the composer.json file has been modified in the previous step, the
|
# Since the composer.json file has been modified in the previous step, the
|
||||||
# composer.lock file needs to be updated.
|
# composer.lock file needs to be updated.
|
||||||
COMPOSER_ROOT_VERSION="${version}" \
|
|
||||||
composer \
|
composer \
|
||||||
--lock \
|
--lock \
|
||||||
--no-ansi \
|
--no-ansi \
|
||||||
|
@ -134,11 +139,10 @@ composerInstallCheckHook() {
|
||||||
composerInstallInstallHook() {
|
composerInstallInstallHook() {
|
||||||
echo "Executing composerInstallInstallHook"
|
echo "Executing composerInstallInstallHook"
|
||||||
|
|
||||||
|
setComposeRootVersion
|
||||||
|
|
||||||
# Finally, run `composer install` to install the dependencies and generate
|
# Finally, run `composer install` to install the dependencies and generate
|
||||||
# the autoloader.
|
# the autoloader.
|
||||||
# The COMPOSER_ROOT_VERSION environment variable is needed only for
|
|
||||||
# vimeo/psalm.
|
|
||||||
COMPOSER_ROOT_VERSION="${version}" \
|
|
||||||
composer \
|
composer \
|
||||||
--no-ansi \
|
--no-ansi \
|
||||||
--no-interaction \
|
--no-interaction \
|
||||||
|
|
|
@ -10,6 +10,8 @@ preBuildHooks+=(composerRepositoryBuildHook)
|
||||||
preCheckHooks+=(composerRepositoryCheckHook)
|
preCheckHooks+=(composerRepositoryCheckHook)
|
||||||
preInstallHooks+=(composerRepositoryInstallHook)
|
preInstallHooks+=(composerRepositoryInstallHook)
|
||||||
|
|
||||||
|
source @phpScriptUtils@
|
||||||
|
|
||||||
composerRepositoryConfigureHook() {
|
composerRepositoryConfigureHook() {
|
||||||
echo "Executing composerRepositoryConfigureHook"
|
echo "Executing composerRepositoryConfigureHook"
|
||||||
|
|
||||||
|
@ -18,7 +20,8 @@ composerRepositoryConfigureHook() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -f "composer.lock" ]]; then
|
if [[ ! -f "composer.lock" ]]; then
|
||||||
COMPOSER_ROOT_VERSION="${version}" \
|
setComposeRootVersion
|
||||||
|
|
||||||
composer \
|
composer \
|
||||||
--no-ansi \
|
--no-ansi \
|
||||||
--no-install \
|
--no-install \
|
||||||
|
@ -55,6 +58,8 @@ composerRepositoryBuildHook() {
|
||||||
|
|
||||||
mkdir -p repository
|
mkdir -p repository
|
||||||
|
|
||||||
|
setComposeRootVersion
|
||||||
|
|
||||||
# Build the local composer repository
|
# Build the local composer repository
|
||||||
# The command 'build-local-repo' is provided by the Composer plugin
|
# The command 'build-local-repo' is provided by the Composer plugin
|
||||||
# nix-community/composer-local-repo-plugin.
|
# nix-community/composer-local-repo-plugin.
|
||||||
|
|
|
@ -2,18 +2,28 @@
|
||||||
, makeSetupHook
|
, makeSetupHook
|
||||||
, diffutils
|
, diffutils
|
||||||
, jq
|
, jq
|
||||||
|
, writeShellApplication
|
||||||
, moreutils
|
, moreutils
|
||||||
, makeBinaryWrapper
|
, makeBinaryWrapper
|
||||||
, cacert
|
, cacert
|
||||||
, buildPackages
|
, buildPackages
|
||||||
}:
|
}:
|
||||||
|
|
||||||
|
let
|
||||||
|
php-script-utils = writeShellApplication {
|
||||||
|
name = "php-script-utils";
|
||||||
|
runtimeInputs = [ jq ];
|
||||||
|
text = builtins.readFile ./php-script-utils.bash;
|
||||||
|
};
|
||||||
|
in
|
||||||
{
|
{
|
||||||
composerRepositoryHook = makeSetupHook
|
composerRepositoryHook = makeSetupHook
|
||||||
{
|
{
|
||||||
name = "composer-repository-hook.sh";
|
name = "composer-repository-hook.sh";
|
||||||
propagatedBuildInputs = [ jq moreutils cacert ];
|
propagatedBuildInputs = [ jq moreutils cacert ];
|
||||||
substitutions = { };
|
substitutions = {
|
||||||
|
phpScriptUtils = lib.getExe php-script-utils;
|
||||||
|
};
|
||||||
} ./composer-repository-hook.sh;
|
} ./composer-repository-hook.sh;
|
||||||
|
|
||||||
composerInstallHook = makeSetupHook
|
composerInstallHook = makeSetupHook
|
||||||
|
@ -24,6 +34,7 @@
|
||||||
# Specify the stdenv's `diff` by abspath to ensure that the user's build
|
# Specify the stdenv's `diff` by abspath to ensure that the user's build
|
||||||
# inputs do not cause us to find the wrong `diff`.
|
# inputs do not cause us to find the wrong `diff`.
|
||||||
cmp = "${lib.getBin buildPackages.diffutils}/bin/cmp";
|
cmp = "${lib.getBin buildPackages.diffutils}/bin/cmp";
|
||||||
|
phpScriptUtils = lib.getExe php-script-utils;
|
||||||
};
|
};
|
||||||
} ./composer-install-hook.sh;
|
} ./composer-install-hook.sh;
|
||||||
}
|
}
|
||||||
|
|
12
pkgs/build-support/php/hooks/php-script-utils.bash
Normal file
12
pkgs/build-support/php/hooks/php-script-utils.bash
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
declare version
|
||||||
|
|
||||||
|
setComposeRootVersion() {
|
||||||
|
set +e # Disable exit on error
|
||||||
|
|
||||||
|
if [[ -v version ]]; then
|
||||||
|
echo -e "\e[32mSetting COMPOSER_ROOT_VERSION to $version\e[0m"
|
||||||
|
export COMPOSER_ROOT_VERSION=$version
|
||||||
|
fi
|
||||||
|
|
||||||
|
set -e
|
||||||
|
}
|
Loading…
Reference in a new issue