Unverified Commit 3a19a727 authored by Thomas Gerbet's avatar Thomas Gerbet Committed by GitHub
Browse files

Merge pull request #285828 from drupol/php/remove-COMPOSER-ROOT-VERSION-env

build-support/php: set `COMPOSER_ROOT_VERSION` environment variable
parents d8e0944e ddb92f07
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -9,6 +9,8 @@ preBuildHooks+=(composerInstallBuildHook)
preCheckHooks+=(composerInstallCheckHook)
preInstallHooks+=(composerInstallInstallHook)

source @phpScriptUtils@

composerInstallConfigureHook() {
    echo "Executing composerInstallConfigureHook"

@@ -22,6 +24,8 @@ composerInstallConfigureHook() {
    fi

    if [[ ! -f "composer.lock" ]]; then
        setComposeRootVersion

        composer \
            --no-ansi \
            --no-install \
@@ -75,6 +79,8 @@ composerInstallConfigureHook() {
composerInstallBuildHook() {
    echo "Executing composerInstallBuildHook"

    setComposeRootVersion

    # Since this file cannot be generated in the composer-repository-hook.sh
    # because the file contains hardcoded nix store paths, we generate it here.
    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
    # composer.lock file needs to be updated.
    COMPOSER_ROOT_VERSION="${version}" \
    composer \
      --lock \
      --no-ansi \
@@ -134,11 +139,10 @@ composerInstallCheckHook() {
composerInstallInstallHook() {
    echo "Executing composerInstallInstallHook"

    setComposeRootVersion

    # Finally, run `composer install` to install the dependencies and generate
    # the autoloader.
    # The COMPOSER_ROOT_VERSION environment variable is needed only for
    # vimeo/psalm.
    COMPOSER_ROOT_VERSION="${version}" \
    composer \
      --no-ansi \
      --no-interaction \
+6 −1
Original line number Diff line number Diff line
@@ -10,6 +10,8 @@ preBuildHooks+=(composerRepositoryBuildHook)
preCheckHooks+=(composerRepositoryCheckHook)
preInstallHooks+=(composerRepositoryInstallHook)

source @phpScriptUtils@

composerRepositoryConfigureHook() {
    echo "Executing composerRepositoryConfigureHook"

@@ -18,7 +20,8 @@ composerRepositoryConfigureHook() {
    fi

    if [[ ! -f "composer.lock" ]]; then
        COMPOSER_ROOT_VERSION="${version}" \
        setComposeRootVersion

        composer \
            --no-ansi \
            --no-install \
@@ -55,6 +58,8 @@ composerRepositoryBuildHook() {

    mkdir -p repository

    setComposeRootVersion

    # Build the local composer repository
    # The command 'build-local-repo' is provided by the Composer plugin
    # nix-community/composer-local-repo-plugin.
+12 −1
Original line number Diff line number Diff line
@@ -2,18 +2,28 @@
, makeSetupHook
, diffutils
, jq
, writeShellApplication
, moreutils
, makeBinaryWrapper
, cacert
, buildPackages
}:

let
  php-script-utils = writeShellApplication {
    name = "php-script-utils";
    runtimeInputs = [ jq ];
    text = builtins.readFile ./php-script-utils.bash;
  };
in
{
  composerRepositoryHook = makeSetupHook
    {
      name = "composer-repository-hook.sh";
      propagatedBuildInputs = [ jq moreutils cacert ];
      substitutions = { };
      substitutions = {
        phpScriptUtils = lib.getExe php-script-utils;
      };
    } ./composer-repository-hook.sh;

  composerInstallHook = makeSetupHook
@@ -24,6 +34,7 @@
        # Specify the stdenv's `diff` by abspath to ensure that the user's build
        # inputs do not cause us to find the wrong `diff`.
        cmp = "${lib.getBin buildPackages.diffutils}/bin/cmp";
        phpScriptUtils = lib.getExe php-script-utils;
      };
    } ./composer-install-hook.sh;
}
+12 −0
Original line number Diff line number Diff line
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
}
+17 −27
Original line number Diff line number Diff line
{ mkDerivation, fetchurl, makeWrapper, installShellFiles, lib, php }:
{ lib
, fetchFromGitHub
, php
}:

mkDerivation rec {
php.buildComposerProject (finalAttrs: {
  pname = "deployer";
  version = "6.8.0";
  version = "7.3.3";

  src = fetchurl {
    url = "https://deployer.org/releases/v${version}/${pname}.phar";
    sha256 = "09mxwfa7yszsiljbkxpsd4sghqngl08cn18v4g1fbsxp3ib3kxi5";
  src = fetchFromGitHub {
    owner = "deployphp";
    repo = "deployer";
    rev = "v${finalAttrs.version}^";
    hash = "sha256-zvK7NwIACAhWN/7D8lVY1Bv8x6xKAp/L826SovQhDYg=";
  };

  dontUnpack = true;
  vendorHash = "sha256-BDq2uryNWC31AEAEZJL9zGaAPbhXZ6hmfpsnr4wlixE=";

  nativeBuildInputs = [ makeWrapper installShellFiles ];

  installPhase = ''
    runHook preInstall
    mkdir -p $out/bin
    install -D $src $out/libexec/deployer/deployer.phar
    makeWrapper ${php}/bin/php $out/bin/dep --add-flags "$out/libexec/deployer/deployer.phar"

    # fish support currently broken: https://github.com/deployphp/deployer/issues/2527
    installShellCompletion --cmd dep \
      --bash <($out/bin/dep autocomplete --install) \
      --zsh <($out/bin/dep autocomplete --install)
    runHook postInstall
  '';

  meta = with lib; {
    description = "A deployment tool for PHP";
    license = licenses.mit;
  meta = {
    description = "The PHP deployment tool with support for popular frameworks out of the box";
    homepage = "https://deployer.org/";
    license = lib.licenses.mit;
    mainProgram = "dep";
    maintainers = with maintainers; teams.php.members;
    maintainers = lib.teams.php.members;
  };
}
})
Loading