diff --git a/pkgs/build-support/php/builders/v1/build-composer-project.nix b/pkgs/build-support/php/builders/v1/build-composer-project.nix index 698391ad1603..912fe7d72f3c 100644 --- a/pkgs/build-support/php/builders/v1/build-composer-project.nix +++ b/pkgs/build-support/php/builders/v1/build-composer-project.nix @@ -94,12 +94,6 @@ let or (if finalAttrs.composerRepository.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 { } // { platforms = lib.platforms.all; }; diff --git a/pkgs/build-support/php/builders/v1/build-composer-repository.nix b/pkgs/build-support/php/builders/v1/build-composer-repository.nix index 037d8bdeb3eb..c16056ce8fdf 100644 --- a/pkgs/build-support/php/builders/v1/build-composer-repository.nix +++ b/pkgs/build-support/php/builders/v1/build-composer-repository.nix @@ -102,13 +102,6 @@ let runHook postInstallCheck ''; - env = { - COMPOSER_CACHE_DIR = "/dev/null"; - COMPOSER_MIRROR_PATH_REPOS = "1"; - COMPOSER_HTACCESS_PROTECT = "0"; - COMPOSER_DISABLE_NETWORK = "0"; - }; - outputHashMode = "recursive"; outputHashAlgo = if (finalAttrs ? vendorHash && finalAttrs.vendorHash != "") then null else "sha256"; diff --git a/pkgs/build-support/php/builders/v1/build-composer-with-plugin.nix b/pkgs/build-support/php/builders/v1/build-composer-with-plugin.nix index 060b51241e6c..e199000f4f7b 100644 --- a/pkgs/build-support/php/builders/v1/build-composer-with-plugin.nix +++ b/pkgs/build-support/php/builders/v1/build-composer-with-plugin.nix @@ -149,12 +149,6 @@ let 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 diff --git a/pkgs/build-support/php/builders/v1/hooks/composer-install-hook.sh b/pkgs/build-support/php/builders/v1/hooks/composer-install-hook.sh index 44e87d06d3a5..d69050ecc6a4 100644 --- a/pkgs/build-support/php/builders/v1/hooks/composer-install-hook.sh +++ b/pkgs/build-support/php/builders/v1/hooks/composer-install-hook.sh @@ -24,7 +24,7 @@ composerInstallConfigureHook() { fi if [[ ! -f "composer.lock" ]]; then - setComposeRootVersion + setComposerRootVersion composer \ --no-install \ @@ -79,7 +79,7 @@ composerInstallConfigureHook() { composerInstallBuildHook() { echo "Executing composerInstallBuildHook" - setComposeRootVersion + setComposerRootVersion # Since this file cannot be generated in the composer-repository-hook.sh # because the file contains hardcoded nix store paths, we generate it here. @@ -99,7 +99,8 @@ composerInstallCheckHook() { composerInstallInstallHook() { echo "Executing composerInstallInstallHook" - setComposeRootVersion + setComposerRootVersion + setComposerEnvVariables # Finally, run `composer install` to install the dependencies and generate # the autoloader. diff --git a/pkgs/build-support/php/builders/v1/hooks/composer-repository-hook.sh b/pkgs/build-support/php/builders/v1/hooks/composer-repository-hook.sh index ec9777541fc0..9d7b048870ee 100644 --- a/pkgs/build-support/php/builders/v1/hooks/composer-repository-hook.sh +++ b/pkgs/build-support/php/builders/v1/hooks/composer-repository-hook.sh @@ -20,7 +20,7 @@ composerRepositoryConfigureHook() { fi if [[ ! -f "composer.lock" ]]; then - setComposeRootVersion + setComposerRootVersion composer \ --no-install \ @@ -58,7 +58,7 @@ composerRepositoryBuildHook() { mkdir -p repository - setComposeRootVersion + setComposerRootVersion # Build the local composer repository # The command 'build-local-repo' is provided by the Composer plugin diff --git a/pkgs/build-support/php/builders/v1/hooks/composer-with-plugin-vendor-hook.sh b/pkgs/build-support/php/builders/v1/hooks/composer-with-plugin-vendor-hook.sh index 0d88d14094ad..186b72111cca 100644 --- a/pkgs/build-support/php/builders/v1/hooks/composer-with-plugin-vendor-hook.sh +++ b/pkgs/build-support/php/builders/v1/hooks/composer-with-plugin-vendor-hook.sh @@ -28,7 +28,7 @@ composerWithPluginConfigureHook() { cp -ar $src $out/src if [[ ! -f "$out/composer.lock" ]]; then - setComposeRootVersion + setComposerRootVersion composer \ global \ diff --git a/pkgs/build-support/php/builders/v1/hooks/php-script-utils.bash b/pkgs/build-support/php/builders/v1/hooks/php-script-utils.bash index 65c0a3b410f6..d1b8a25c949d 100644 --- a/pkgs/build-support/php/builders/v1/hooks/php-script-utils.bash +++ b/pkgs/build-support/php/builders/v1/hooks/php-script-utils.bash @@ -2,7 +2,7 @@ declare version declare composerStrictValidation declare composerGlobal -setComposeRootVersion() { +setComposerRootVersion() { set +e # Disable exit on error if [[ -v version ]]; then @@ -13,8 +13,15 @@ setComposeRootVersion() { set -e } +setComposerEnvVariables() { + echo -e "\e[32mSetting some required environment variables for Composer...\e[0m" + export COMPOSER_MIRROR_PATH_REPOS=1 + export COMPOSER_CACHE_DIR=/dev/null + export COMPOSER_HTACCESS_PROTECT=0 +} + checkComposerValidate() { - setComposeRootVersion + setComposerRootVersion if [ "1" == "${composerGlobal-}" ]; then global="global"; diff --git a/pkgs/build-support/php/builders/v2/build-composer-project.nix b/pkgs/build-support/php/builders/v2/build-composer-project.nix index 6013225e7c59..bfbd2327812b 100644 --- a/pkgs/build-support/php/builders/v2/build-composer-project.nix +++ b/pkgs/build-support/php/builders/v2/build-composer-project.nix @@ -94,12 +94,6 @@ let or (if finalAttrs.composerVendor.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 { } // { platforms = lib.platforms.all; }; diff --git a/pkgs/build-support/php/builders/v2/build-composer-vendor.nix b/pkgs/build-support/php/builders/v2/build-composer-vendor.nix index b68e16e6cc1a..cbbe643d20f1 100644 --- a/pkgs/build-support/php/builders/v2/build-composer-vendor.nix +++ b/pkgs/build-support/php/builders/v2/build-composer-vendor.nix @@ -87,13 +87,6 @@ let runHook postInstallCheck ''; - env = { - COMPOSER_CACHE_DIR = "/dev/null"; - COMPOSER_MIRROR_PATH_REPOS = "1"; - COMPOSER_HTACCESS_PROTECT = "0"; - COMPOSER_DISABLE_NETWORK = "0"; - }; - outputHashMode = "recursive"; outputHashAlgo = if (finalAttrs ? vendorHash && finalAttrs.vendorHash != "") then null else "sha256"; diff --git a/pkgs/build-support/php/builders/v2/hooks/composer-install-hook.sh b/pkgs/build-support/php/builders/v2/hooks/composer-install-hook.sh index 7cc176058b50..0b04af622233 100644 --- a/pkgs/build-support/php/builders/v2/hooks/composer-install-hook.sh +++ b/pkgs/build-support/php/builders/v2/hooks/composer-install-hook.sh @@ -14,7 +14,7 @@ source @phpScriptUtils@ composerInstallConfigureHook() { echo "Executing composerInstallConfigureHook" - setComposeRootVersion + setComposerRootVersion if [[ ! -e "${composerVendor}" ]]; then echo "No local composer vendor found." diff --git a/pkgs/build-support/php/builders/v2/hooks/composer-vendor-hook.sh b/pkgs/build-support/php/builders/v2/hooks/composer-vendor-hook.sh index f6d1157456f7..24f3eaa2744e 100644 --- a/pkgs/build-support/php/builders/v2/hooks/composer-vendor-hook.sh +++ b/pkgs/build-support/php/builders/v2/hooks/composer-vendor-hook.sh @@ -15,7 +15,7 @@ source @phpScriptUtils@ composerVendorConfigureHook() { echo "Executing composerVendorConfigureHook" - setComposeRootVersion + setComposerRootVersion if [[ -e "$composerLock" ]]; then echo -e "\e[32mUsing user provided \`composer.lock\` file from \`$composerLock\`\e[0m" @@ -59,11 +59,13 @@ composerVendorConfigureHook() { composerVendorBuildHook() { echo "Executing composerVendorBuildHook" + setComposerEnvVariables + composer \ - # The acpu-autoloader is not reproducible and has to be disabled. - # Upstream PR: https://github.com/composer/composer/pull/12090 - # --apcu-autoloader \ - # --apcu-autoloader-prefix="$(jq -r -c 'try ."content-hash"' < composer.lock)" \ + `# The acpu-autoloader is not reproducible and has to be disabled.` \ + `# Upstream PR: https://github.com/composer/composer/pull/12090` \ + `# --apcu-autoloader` \ + `# --apcu-autoloader-prefix="$(jq -r -c 'try ."content-hash"' < composer.lock)"` \ --no-interaction \ --no-progress \ --optimize-autoloader \ diff --git a/pkgs/build-support/php/builders/v2/hooks/php-script-utils.bash b/pkgs/build-support/php/builders/v2/hooks/php-script-utils.bash index 3e8299bf15d3..573b82c2baff 100644 --- a/pkgs/build-support/php/builders/v2/hooks/php-script-utils.bash +++ b/pkgs/build-support/php/builders/v2/hooks/php-script-utils.bash @@ -2,7 +2,7 @@ declare version declare composerStrictValidation declare composerGlobal -setComposeRootVersion() { +setComposerRootVersion() { set +e # Disable exit on error if [[ -v version ]]; then @@ -13,6 +13,13 @@ setComposeRootVersion() { set -e } +setComposerEnvVariables() { + echo -e "\e[32mSetting some required environment variables for Composer...\e[0m" + export COMPOSER_MIRROR_PATH_REPOS=1 + export COMPOSER_CACHE_DIR=/dev/null + export COMPOSER_HTACCESS_PROTECT=0 +} + checkComposerValidate() { if [ "1" == "${composerGlobal-}" ]; then global="global";