Integrate Flatpak to your favorite IDE

Bilal Elmoussaoui bil.elmoussaoui@gmail.com

The Story

The Process

Detect and parse the manifest

Check if the required SDKs are installed

  • Ideally offer to install them for the user
  • Complexity of handling --user and --system installations
						flatpak list --runtime --columns=application,branch
					
Initialize the Flatpak repository

						flatpak build-init $repoDir $appID $SDK \
				$runtime $runtimeVersion
					
Update and build dependencies

  • Assume the latest module is the application
  • Make use of --stop-at=$module
  • Allow to run any time once the repo is initialized
						# Update dependencies
flatpak-builder --stop-at=$module --download-only \
	--ccache --force-clean --state-dir=$stateDir \
	$repoDir $manifestPath
	# Build dependencies
flatpak-builder --stop-at=$module --build-only \
	--ccache --force-clean --state-dir=$stateDir \
	--disable-download --keep-build-dirs \
	$repoDir $manifestPath
					
Build the application

  • Buildsystem dependant
  • Handling $PATH / LD_LIBRARY_PATH / PKG_CONFIG_PATH
  • Handling the manifest and module's build-options
  • Post install
Run the application

  • Make sure to skip --metadata from finish-args
						flatpak build --with-appdir --allow=devel \
	--talk-name=org.freedesktop.portal.* \
	--talk-name=org.a11y.Bus \
	$finishArgs \
	$repoDir $commandToRun
					

Edge cases

Sandboxed IDE
  • Use flatpak-spawn for running flatpak/flatpak-builder on the host
  • Use org.flatpak.Builder Flatpak if installed, especially on OSTree based OSs
Ensure the documents portal is running
Mounting fonts
Proxying host environment variables
Proxying the accessibility bus

Bonus points

Integrate the SDK extensions
  • Running Language service providers, ...etc
  • Avoids having to install anything on the host
Runtime terminal
Build terminal
Export as a bundle

Examples

GNOME Builder
https://flathub.org/apps/details/org.gnome.Builder

  • The best container-integrated IDE
  • Smooth integration with the LSP using SDK extensions
Flatpak VSCode
https://github.com/bilelmoussaoui/flatpak-vscode

  • Inspired by GNOME Builder
  • Integrates with other VSCode extensions like rust-analyzer, meson, vala
fenv
https://gitlab.gnome.org/ZanderBrown/fenv

  • Inspired by Flatpak VSCode
  • CLI friendly
  • Still on a beta phase

Open questions

Handle a lot of corner cases
Shared cache between various IDEs
Duplicate parts of flatpak-builder for building the application
Duplicate parts of flatpak for running the application
Potential solutions


  • libflatpak-builder maybe?
  • Simpler CLI wrapper that various IDEs could make use of

Any questions?