Skip to content

Commit 568bfef

Browse files
authored
build-support/php: fix environment variables for Composer (#343900)
2 parents 79d3272 + 95f5cf7 commit 568bfef

12 files changed

+32
-47
lines changed

pkgs/build-support/php/builders/v1/build-composer-project.nix

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,6 @@ let
9494
or (if finalAttrs.composerRepository.composerLock == null then nix-update-script { } else null);
9595
};
9696

97-
env = {
98-
COMPOSER_CACHE_DIR = "/dev/null";
99-
COMPOSER_DISABLE_NETWORK = "1";
100-
COMPOSER_MIRROR_PATH_REPOS = "1";
101-
};
102-
10397
meta = previousAttrs.meta or { } // {
10498
platforms = lib.platforms.all;
10599
};

pkgs/build-support/php/builders/v1/build-composer-repository.nix

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,6 @@ let
102102
runHook postInstallCheck
103103
'';
104104

105-
env = {
106-
COMPOSER_CACHE_DIR = "/dev/null";
107-
COMPOSER_MIRROR_PATH_REPOS = "1";
108-
COMPOSER_HTACCESS_PROTECT = "0";
109-
COMPOSER_DISABLE_NETWORK = "0";
110-
};
111-
112105
outputHashMode = "recursive";
113106
outputHashAlgo =
114107
if (finalAttrs ? vendorHash && finalAttrs.vendorHash != "") then null else "sha256";

pkgs/build-support/php/builders/v1/build-composer-with-plugin.nix

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,6 @@ let
149149
or (if finalAttrs.vendor.composerLock == null then nix-update-script { } else null);
150150
};
151151

152-
env = {
153-
COMPOSER_CACHE_DIR = "/dev/null";
154-
COMPOSER_DISABLE_NETWORK = "1";
155-
COMPOSER_MIRROR_PATH_REPOS = "1";
156-
};
157-
158152
meta = previousAttrs.meta or composer.meta;
159153
};
160154
in

pkgs/build-support/php/builders/v1/hooks/composer-install-hook.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ composerInstallConfigureHook() {
2424
fi
2525

2626
if [[ ! -f "composer.lock" ]]; then
27-
setComposeRootVersion
27+
setComposerRootVersion
2828

2929
composer \
3030
--no-install \
@@ -79,7 +79,7 @@ composerInstallConfigureHook() {
7979
composerInstallBuildHook() {
8080
echo "Executing composerInstallBuildHook"
8181

82-
setComposeRootVersion
82+
setComposerRootVersion
8383

8484
# Since this file cannot be generated in the composer-repository-hook.sh
8585
# because the file contains hardcoded nix store paths, we generate it here.
@@ -99,7 +99,8 @@ composerInstallCheckHook() {
9999
composerInstallInstallHook() {
100100
echo "Executing composerInstallInstallHook"
101101

102-
setComposeRootVersion
102+
setComposerRootVersion
103+
setComposerEnvVariables
103104

104105
# Finally, run `composer install` to install the dependencies and generate
105106
# the autoloader.

pkgs/build-support/php/builders/v1/hooks/composer-repository-hook.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ composerRepositoryConfigureHook() {
2020
fi
2121

2222
if [[ ! -f "composer.lock" ]]; then
23-
setComposeRootVersion
23+
setComposerRootVersion
2424

2525
composer \
2626
--no-install \
@@ -58,7 +58,7 @@ composerRepositoryBuildHook() {
5858

5959
mkdir -p repository
6060

61-
setComposeRootVersion
61+
setComposerRootVersion
6262

6363
# Build the local composer repository
6464
# The command 'build-local-repo' is provided by the Composer plugin

pkgs/build-support/php/builders/v1/hooks/composer-with-plugin-vendor-hook.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ composerWithPluginConfigureHook() {
2828
cp -ar $src $out/src
2929

3030
if [[ ! -f "$out/composer.lock" ]]; then
31-
setComposeRootVersion
31+
setComposerRootVersion
3232

3333
composer \
3434
global \

pkgs/build-support/php/builders/v1/hooks/php-script-utils.bash

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ declare version
22
declare composerStrictValidation
33
declare composerGlobal
44

5-
setComposeRootVersion() {
5+
setComposerRootVersion() {
66
set +e # Disable exit on error
77

88
if [[ -v version ]]; then
@@ -13,8 +13,15 @@ setComposeRootVersion() {
1313
set -e
1414
}
1515

16+
setComposerEnvVariables() {
17+
echo -e "\e[32mSetting some required environment variables for Composer...\e[0m"
18+
export COMPOSER_MIRROR_PATH_REPOS=1
19+
export COMPOSER_CACHE_DIR=/dev/null
20+
export COMPOSER_HTACCESS_PROTECT=0
21+
}
22+
1623
checkComposerValidate() {
17-
setComposeRootVersion
24+
setComposerRootVersion
1825

1926
if [ "1" == "${composerGlobal-}" ]; then
2027
global="global";

pkgs/build-support/php/builders/v2/build-composer-project.nix

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,6 @@ let
9494
or (if finalAttrs.composerVendor.composerLock == null then nix-update-script { } else null);
9595
};
9696

97-
env = {
98-
COMPOSER_CACHE_DIR = "/dev/null";
99-
COMPOSER_DISABLE_NETWORK = "1";
100-
COMPOSER_MIRROR_PATH_REPOS = "1";
101-
};
102-
10397
meta = previousAttrs.meta or { } // {
10498
platforms = lib.platforms.all;
10599
};

pkgs/build-support/php/builders/v2/build-composer-vendor.nix

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,6 @@ let
8787
runHook postInstallCheck
8888
'';
8989

90-
env = {
91-
COMPOSER_CACHE_DIR = "/dev/null";
92-
COMPOSER_MIRROR_PATH_REPOS = "1";
93-
COMPOSER_HTACCESS_PROTECT = "0";
94-
COMPOSER_DISABLE_NETWORK = "0";
95-
};
96-
9790
outputHashMode = "recursive";
9891
outputHashAlgo =
9992
if (finalAttrs ? vendorHash && finalAttrs.vendorHash != "") then null else "sha256";

pkgs/build-support/php/builders/v2/hooks/composer-install-hook.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ source @phpScriptUtils@
1414
composerInstallConfigureHook() {
1515
echo "Executing composerInstallConfigureHook"
1616

17-
setComposeRootVersion
17+
setComposerRootVersion
1818

1919
if [[ ! -e "${composerVendor}" ]]; then
2020
echo "No local composer vendor found."

0 commit comments

Comments
 (0)