Problem/Motivation

We support install profiles, to customize the installation experience to some degree.

And we support installing Drupal from a recipe, bypassing the profile entirely.

But what we don't yet support is the in-between zone: you want to customize the install experience, but you also want to apply a recipe (or set of recipes) at install time. This grey zone is where Drupal CMS exists, and it needs to do some hacky workarounds to make that possible.

Proposed resolution

Allow a profile's info file to specify a list of recipes that should be applied once modules are installed. These recipes would be applied in the order they are listed, by appending their batch operations to the ones from install_profile_modules.

User interface changes

None.

Introduced terminology

None.

API changes

A new recipes key would be supported in profile info files.

Release notes snippet

TBD

Issue fork drupal-3605549

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

phenaproxima created an issue. See original summary.

phenaproxima’s picture

Status: Active » Needs review

Added this new ability, and a basic test to prove it works with core recipes.

The main missing thing here is path resolution. Core recipe paths are used as-is, but if we add this ability, then we need to resolve recipe directory paths relative to...somewhere. How should we handle that? A few possibilities:

  • We could always resolve the paths relative to the web root, so in a drupal/recommended-project layout, the paths would be listed as ../recipes/foo. This is the simplest, but it means profiles using this superpower would be tightly coupled to the project layout.
  • We could introspect the Composer configuration for the project to determine where drupal-recipe packages will be installed, and resolve relative to that. This is what Drupal CMS does, and is probably the most robust choice.
  • We could do some kind of lightweight "recipe discovery" where we scan certain directories for recipes, at install time only.
  • We could add an $install_state['recipes_directory'] variable, defaulting to ../recipes. This could be overridden programmatically by calling install_drupal() directly, or by a custom profile which does a similar thing. This is probably the most lightweight "configurable" option, since $install_state is already a hodgepodge of various state flags used only by the installer.
  • We could also do nothing to address this, and leave the patch as-is. This approach would force custom profiles which want to use this superpower to fully resolve the recipe paths on their own and inject them into $install_state['profile_info'].

Or maybe something else?

gábor hojtsy’s picture

This also needs to take into account translation at one point. If not here then modified later to do it :) That the recipe should get its translation file downloaded prior to being applied. The data from such .po file is not currently used but will be after #3472317: Config language adaptation and translation does not happen at all when config is applied from a recipe.

gábor hojtsy’s picture

Status: Needs review » Reviewed & tested by the community

Anyway recipes do not support that yet, so we can get this in like so, I think its quite simple and elegant and well tested :)

gábor hojtsy’s picture

catch’s picture

This looks good. Maybe we can get the new slimmed down standard profile to install from a recipe and remove its shipped config just based on this issue?

Of the four options for directory discovery, this sounds encouraging, although also something we could do in a follow-up once this is committed.

We could introspect the Composer configuration for the project to determine where drupal-recipe packages will be installed, and resolve relative to that. This is what Drupal CMS does, and is probably the most robust choice.

However if we do that, what happens to core recipes in that case? Should we just special-case the core directory and get everything else from the recipes directory? Was also wondering here about recipes shipped inside the profile directory.

phenaproxima’s picture

However if we do that, what happens to core recipes in that case? Should we just special-case the core directory and get everything else from the recipes directory?

Yes. We already explicitly make an allowance for core recipes in the recipe system, so we'd just be doing the same thing here. Either the referenced recipe is a directory relative to the web root, or it's derived from the Composer install location.

Was also wondering here about recipes shipped inside the profile directory.

Is that something we need to support? IMHO, we shouldn't. Recipes are atomic Composer packages, and part of the rationale for that was specifically to avoid the "modules can contain other modules, oh and also the profile can have them too" extension scanning dance inherited from Ye Olden Days.

If a profile wants to include recipes, it needs to reference them as Composer dependencies. It doesn't get to ship them internally. :) Recipes are deliberately Composer-native.

catch’s picture

Issue tags: +Needs followup

Thanks #8 makes sense. In that case I think we just need a follow-up to implement:

We could introspect the Composer configuration for the project to determine where drupal-recipe packages will be installed, and resolve relative to that. This is what Drupal CMS does, and is probably the most robust choice.

  • catch committed 76e20833 on 11.x
    feat: #3605549 Allow install profiles to specify a list of recipes that...

  • catch committed b0f28bf1 on main
    feat: #3605549 Allow install profiles to specify a list of recipes that...
catch’s picture

Version: main » 11.x-dev
Status: Reviewed & tested by the community » Fixed

Let's get this in.

Do we need a separate follow-up to implement recipe translation in the installer or should that be folded into #3472317: Config language adaptation and translation does not happen at all when config is applied from a recipe ?

Also think we should have a follow-up to try to use the standard profile recipe in standard profile and drop the config.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

catch’s picture

Status: Fixed » Needs work
Issue tags: +Needs change record

Also we should have a change record to inform people this is possible. Re-opening for that.

phenaproxima’s picture

phenaproxima’s picture

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.