A couple trivial(?) questions about extensions

The official docs seem a bit sparse on precisely how extensions are applied to one’s snapcraft.yaml file, so I did some testing and want to confirm my understanding (tested by running “snapcraft expand-extensions” to see the results. (I did this with the experimental ros2_foxy extension, but that should not affect the results.)

First, as explained here, https://github.com/snapcore/snapcraft/blob/main/snapcraft/internal/project_loader/_extensions/_extension.py#L23-L36, an extension allows you to define four types of applied content:

  • new root/global content
  • additional (existing) apps content
  • additional (existing) parts content
  • totally new parts to be added to support the extension

However, as I read the snapcraft schema file (and based on testing), the only place you can specify an extension in your snapcraft.yaml file is in an apps: entry, whereupon:

  • the additional apps content defined by the extension is added only to those apps that refer to the extension, and
  • as soon as you add a reference to that extension to any app in snapcraft.yaml, all the rest of the content of the extension is applied everywhere else (globally, and to parts)

This might seem self-evident after perusal, but it was not clear just from the online docs, so is this explanation accurate?