diff --git a/pkgs/build-support/php/build-composer-project.nix b/pkgs/build-support/php/build-composer-project.nix index b0be330205fa..6aecf4345773 100644 --- a/pkgs/build-support/php/build-composer-project.nix +++ b/pkgs/build-support/php/build-composer-project.nix @@ -7,9 +7,13 @@ let phpDrv = finalAttrs.php or php; composer = finalAttrs.composer or phpDrv.packages.composer; composer-local-repo-plugin = callPackage ./pkgs/composer-local-repo-plugin.nix { }; - composerLock = finalAttrs.composerLock or null; in { + composerLock = previousAttrs.composerLock or null; + composerNoDev = previousAttrs.composerNoDev or true; + composerNoPlugins = previousAttrs.composerNoPlugins or true; + composerNoScripts = previousAttrs.composerNoScripts or true; + nativeBuildInputs = (previousAttrs.nativeBuildInputs or [ ]) ++ [ composer composer-local-repo-plugin @@ -50,8 +54,13 @@ let ''; composerRepository = phpDrv.mkComposerRepository { - inherit composer composer-local-repo-plugin composerLock; + 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; }; meta = previousAttrs.meta or { } // { diff --git a/pkgs/build-support/php/build-composer-repository.nix b/pkgs/build-support/php/build-composer-repository.nix index 86362f151f09..30b0b48de751 100644 --- a/pkgs/build-support/php/build-composer-repository.nix +++ b/pkgs/build-support/php/build-composer-repository.nix @@ -25,7 +25,14 @@ let assert (lib.assertMsg (previousAttrs ? vendorHash) "mkComposerRepository expects vendorHash argument."); assert (lib.assertMsg (previousAttrs ? version) "mkComposerRepository expects version argument."); assert (lib.assertMsg (previousAttrs ? pname) "mkComposerRepository expects pname argument."); + assert (lib.assertMsg (previousAttrs ? composerNoDev) "mkComposerRepository expects composerNoDev argument."); + assert (lib.assertMsg (previousAttrs ? composerNoPlugins) "mkComposerRepository expects composerNoPlugins argument."); + assert (lib.assertMsg (previousAttrs ? composerNoScripts) "mkComposerRepository expects composerNoScripts argument."); { + composerNoDev = previousAttrs.composerNoDev or true; + composerNoPlugins = previousAttrs.composerNoPlugins or true; + composerNoScripts = previousAttrs.composerNoScripts or true; + name = "${previousAttrs.pname}-${previousAttrs.version}-composer-repository"; # See https://github.com/NixOS/nix/issues/6660 diff --git a/pkgs/build-support/php/hooks/composer-install-hook.sh b/pkgs/build-support/php/hooks/composer-install-hook.sh index 2d5c90ea3b2f..9f23b90fa401 100644 --- a/pkgs/build-support/php/hooks/composer-install-hook.sh +++ b/pkgs/build-support/php/hooks/composer-install-hook.sh @@ -1,6 +1,8 @@ -declare composerHomeDir declare composerRepository declare version +declare composerNoDev +declare composerNoPlugins +declare composerNoScripts preConfigureHooks+=(composerInstallConfigureHook) preBuildHooks+=(composerInstallBuildHook) @@ -59,8 +61,9 @@ composerInstallBuildHook() { --no-ansi \ --no-install \ --no-interaction \ - --no-plugins \ - --no-scripts \ + ${composerNoDev:+--no-dev} \ + ${composerNoPlugins:+--no-plugins} \ + ${composerNoScripts:+--no-scripts} \ update echo "Finished composerInstallBuildHook" @@ -88,8 +91,9 @@ composerInstallInstallHook() { composer \ --no-ansi \ --no-interaction \ - --no-scripts \ - --no-plugins \ + ${composerNoDev:+--no-dev} \ + ${composerNoPlugins:+--no-plugins} \ + ${composerNoScripts:+--no-scripts} \ install # Remove packages.json, we don't need it in the store. diff --git a/pkgs/build-support/php/hooks/composer-repository-hook.sh b/pkgs/build-support/php/hooks/composer-repository-hook.sh index 707c94452256..057acf1fcc30 100644 --- a/pkgs/build-support/php/hooks/composer-repository-hook.sh +++ b/pkgs/build-support/php/hooks/composer-repository-hook.sh @@ -1,6 +1,8 @@ -declare composerHomeDir declare composerLock declare version +declare composerNoDev +declare composerNoPlugins +declare composerNoScripts preConfigureHooks+=(composerRepositoryConfigureHook) preBuildHooks+=(composerRepositoryBuildHook) @@ -20,8 +22,9 @@ composerRepositoryConfigureHook() { --no-ansi \ --no-install \ --no-interaction \ - --no-plugins \ - --no-scripts \ + ${composerNoDev:+--no-dev} \ + ${composerNoPlugins:+--no-plugins} \ + ${composerNoScripts:+--no-scripts} \ update echo "Using an autogenerated composer.lock file." fi @@ -38,7 +41,7 @@ composerRepositoryBuildHook() { # The command 'build-local-repo' is provided by the Composer plugin # nix-community/composer-local-repo-plugin. COMPOSER_CACHE_DIR=/dev/null \ - composer-local-repo-plugin --no-ansi build-local-repo -r repository + composer-local-repo-plugin --no-ansi build-local-repo ${composerNoDev:+--no-dev} -r repository echo "Finished composerRepositoryBuildHook" }