flatpak
flatpak copied to clipboard
Providing access to system icons and fonts from "flatpak build"
The GNOME Builder IDE is very much designed around the flatpak build pipeline. Even so much as running your program is actually daisy chained upon flatpak build
. However, this is mostly because the requirement to make incremental OSTree commits every the user hits run/build/etc would be too much.
This has a few drawbacks, one of which is that we don't get access to fonts and icons like you do from flatpak run
.
I wanted to use this issue as a way to discuss what sort of options we have, and strategize in a direction.
One possibility that comes to mind is that we could duplicate the code to create an alternate font-cache from add_font_path_args()
. Presumably we'd need to use --bind-mount=
in similar fashion.
The one thing we lose with --bind-mount=DEST=SRC
is that the bind mount is read-write, which means we may end up in a position where font caches are updated where we want to avoid that. Although perhaps we can --filesystem=PATH:ro
as an alternative for the locations the user has write access to.
Mounting the fonts are now duplicated (at least) in three projects:
- GNOME Builder: https://gitlab.gnome.org/GNOME/gnome-builder/-/blob/b6458faa9c592afdea444780828f983cda01126d/src/plugins/flatpak/gbp-flatpak-aux.c#L84
- flatpak-vscode: https://github.com/bilelmoussaoui/flatpak-vscode/blob/6e8f203c23dfb9c03153058e558de22b184cf208/src/utils.ts#L149-L183
- fenv: https://gitlab.gnome.org/ZanderBrown/fenv/-/blob/2370679762608507aae9a7c705e398f8db34758f/src/fontdirs.rs
Seems like there is a common need for mounting fonts (and a11y bus) in flatpak build
.
Any objections of adding flatpak build --share=fonts
? Minimal code change would be to move add_font_path_args to be part of the common/flatpak-bwrap.c
API, and chain that up to the build command.
This would allow flatpak-builder --run
(and possibly gnome builder too) to reuse the same logic.
I don't think Builder can use it because we use a flatpak
binary from the host and we support relatively far back to old versions (the Flatpak runs on CentOS 7 for example). Or rather we could use it, but we'd still have to have our code too so it's just twice the code-paths.