Skip to content

Commit

Permalink
Merge pull request #309317 from drupol/backport-309314-to-release-23.11
Browse files Browse the repository at this point in the history
[Backport release-23.11] build-support/php: minor refactoring
  • Loading branch information
drupol authored May 5, 2024
2 parents 1c3b5c9 + e671102 commit 6221907
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 24 deletions.
43 changes: 29 additions & 14 deletions pkgs/build-support/php/build-composer-project.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
{ callPackage, stdenvNoCC, lib, writeTextDir, php, makeBinaryWrapper, fetchFromGitHub, fetchurl }:
{
callPackage,
stdenvNoCC,
lib,
php,
fetchFromGitHub,
}:

let
buildComposerProjectOverride = finalAttrs: previousAttrs:
Expand Down Expand Up @@ -62,21 +68,30 @@ let
runHook postInstallCheck
'';

composerRepository = phpDrv.mkComposerRepository {
inherit composer composer-local-repo-plugin;
inherit (finalAttrs) patches pname src vendorHash version;

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;
composerRepository =
previousAttrs.composerRepository or (phpDrv.mkComposerRepository {
inherit composer composer-local-repo-plugin;
inherit (finalAttrs)
patches
pname
src
vendorHash
version
;

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

env = {
COMPOSER_CACHE_DIR = "/dev/null";
COMPOSER_DISABLE_NETWORK = "1";
COMPOSER_MIRROR_PATH_REPOS = "1";
};

COMPOSER_CACHE_DIR="/dev/null";
COMPOSER_DISABLE_NETWORK="1";
COMPOSER_MIRROR_PATH_REPOS="1";

meta = previousAttrs.meta or { } // {
platforms = lib.platforms.all;
};
Expand Down
18 changes: 13 additions & 5 deletions pkgs/build-support/php/build-composer-repository.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
{ callPackage, stdenvNoCC, lib, writeTextDir, fetchFromGitHub, php }:
{
callPackage,
stdenvNoCC,
lib,
fetchFromGitHub,
php,
}:

let
mkComposerRepositoryOverride =
Expand Down Expand Up @@ -83,10 +89,12 @@ let
runHook postInstallCheck
'';

COMPOSER_CACHE_DIR = "/dev/null";
COMPOSER_MIRROR_PATH_REPOS = "1";
COMPOSER_HTACCESS_PROTECT = "0";
COMPOSER_DISABLE_NETWORK = "0";
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";
Expand Down
10 changes: 6 additions & 4 deletions pkgs/build-support/php/pkgs/composer-local-repo-plugin.nix
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ stdenvNoCC.mkDerivation (finalAttrs: {
hash = "sha256-edbn07r/Uc1g0qOuVBZBs6N1bMN5kIfA1b4FCufdw5M=";
};

COMPOSER_CACHE_DIR = "/dev/null";
COMPOSER_MIRROR_PATH_REPOS = "1";
COMPOSER_HTACCESS_PROTECT = "0";
COMPOSER_DISABLE_NETWORK = "1";
env = {
COMPOSER_CACHE_DIR = "/dev/null";
COMPOSER_MIRROR_PATH_REPOS = "1";
COMPOSER_HTACCESS_PROTECT = "0";
COMPOSER_DISABLE_NETWORK = "1";
};

nativeBuildInputs = [
makeBinaryWrapper
Expand Down
3 changes: 2 additions & 1 deletion pkgs/build-support/php/pkgs/composer-phar.nix
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ stdenvNoCC.mkDerivation (finalAttrs: {
mkdir -p $out/bin
install -D $src $out/libexec/composer/composer.phar
makeWrapper ${php}/bin/php $out/bin/composer \
makeWrapper ${lib.getExe php} $out/bin/composer \
--add-flags "$out/libexec/composer/composer.phar" \
--prefix PATH : ${lib.makeBinPath [ _7zz cacert curl git unzip xz ]}
Expand All @@ -44,6 +44,7 @@ stdenvNoCC.mkDerivation (finalAttrs: {
description = "Dependency Manager for PHP, shipped from the PHAR file";
homepage = "https://getcomposer.org/";
license = lib.licenses.mit;
mainProgram = "composer";
maintainers = with lib.maintainers; [ drupol ];
platforms = lib.platforms.all;
};
Expand Down

0 comments on commit 6221907

Please sign in to comment.