Silverblue for Flatpak Development

I am looking to utilize Silverblue for developing a couple of Flatpaks. i have not built flapaks for a couple years :thinking: So I understand things have changed.

There are guides and my notes are all over the place with conflicting information. ( What worked for some applications did not work for others :thinking: ) Google memory and my bookmarks are contributing to the madness.

Is anyone currently building Flatpaks on Silverblue? What tools are you using and how do you have things set up? Portals is a thing more than it was when I tried a long time ago, What are some gotchas if any ?

Tools I’ve used are flatpak-builder, fedmod, rpm2flatpak

Any up to date info would be appreciated.

2 Likes

Just so everyone can have a laugh. . . I decided to ask our AI overlord Gemini (google) :upside_down_face: :robot:

I did ask in English, and am in an English speaking Country/Timezone

So, I’ll go back to my notes and hopefully some community memebers can help me get a refresher on this. :+1:t5: :fedora:

1 Like

Here help for my Gemini 1.5 advanced

Local Flatpak Build Guide
1. Preparation
 * Install Flatpak and flatpak-builder:
   sudo apt install flatpak flatpak-builder

   (or equivalent for your distribution)
 * Create a project directory:
   mkdir myapp && cd myapp

2. Manifest File (myapp.json)
{
  "app-id": "com.example.myapp",
  "runtime": "org.freedesktop.Platform",
  "runtime-version": "23.08",
  "sdk": "org.freedesktop.Sdk",
  "command": "myapp", 
  "modules": [
    {
      "name": "myapp",
      "buildsystem": "simple",
      "build-commands": [
        "./configure --prefix=/app",
        "make",
        "make install"
      ],
      "sources": [
        {
          "type": "archive",
          "url": "https://example.com/myapp-1.0.tar.gz",
          "sha256": "YOUR_SHA256_CHECKSUM" 
        }
      ]
    }
  ]
}

 * Replace com.example.myapp with your app's ID.
 * Adjust runtime-version if needed.
 * Replace download URL and SHA256 checksum.
 * Modify build-commands to fit your project's build process.
3. Building
flatpak-builder --user --install --force-clean build-dir myapp.json

 * This will download, build, and install your app in build-dir.
 * Replace build-dir with your desired directory.
4. Running
flatpak run com.example.myapp

Additional Tips
 * Debugging: If errors occur, check the output in build-dir/appstream/logs.
 * Sandboxing: The manifest's finish-args allows controlling sandbox permissions.
 * Distribution: You can share your built Flatpak by creating a repository and adding it to a remote.
For further information and customization, consult the Flatpak documentation.
1 Like

Gemini is actually terrible in the scenarios I’ve used it for. I’m not sure why I even decided to try to ask it such a question. . . but I did. It also said my English was Chinese. :upside_down_face:


On topic :

Those are tools I’ve used before. flatpak-builder was good in my use case, but there are other quirks here and there. also, I’ll be using a toolbox since it’s on Silverblue. :crossed_fingers:t5:

My Gemini looks and feels sharp I just promted it to change it fedora silverblue 40 guide and seem a pretty legit and added toolbox on prompt

Local Flatpak Build Guide for Fedora Silverblue 40 (using Toolbox)
1. Preparation
 * Update your system:
   rpm-ostree update

 * Enable Toolbox:
   rpm-ostree install toolbox

 * Create and enter a toolbox container:
   toolbox create myflatpak
toolbox enter myflatpak

 * Install required packages:
   sudo dnf install flatpak flatpak-builder

2. Manifest File (myapp.json)
{
  "app-id": "com.example.myapp",
  "runtime": "org.freedesktop.Platform",
  "runtime-version": "23.08",
  "sdk": "org.freedesktop.Sdk",
  "command": "myapp", 
  "modules": [
    {
      "name": "myapp",
      "buildsystem": "simple",
      "build-commands": [
        "./configure --prefix=/app",
        "make",
        "make install"
      ],
      "sources": [
        {
          "type": "archive",
          "url": "https://example.com/myapp-1.0.tar.gz",
          "sha256": "YOUR_SHA256_CHECKSUM" 
        }
      ]
    }
  ]
}

 * Replace com.example.myapp with your app's ID.
 * Adjust runtime-version if needed.
 * Replace download URL and SHA256 checksum.
 * Modify build-commands to fit your project's build process.
3. Building
flatpak-builder --user --install --force-clean build-dir myapp.json

 * This will download, build, and install your app in build-dir.
 * Replace build-dir with your desired directory.
4. Running from Silverblue Host
flatpak run --filesystem=host com.example.myapp

 * The --filesystem=host flag is crucial to access files on your Silverblue host system from within the flatpak.
Additional Tips
 * Debugging: If errors occur, check the output in build-dir/appstream/logs.
 * Sandboxing: The manifest's finish-args allows controlling sandbox permissions.
 * Distribution: You can share your built Flatpak by creating a repository and adding it to a remote.
 * Toolbox: Remember you're building within a Toolbox container. Exit it using exit when done.
For further information and customization, consult the Flatpak documentation.

I will wait for more smarter ones to catch this untill this goes way off topic and water cooler section

I hope not. I’ll do my best to keep this on brand. Hopefully people can chime in with their experiences and tools. Which is what I would like to harbor here. Also get more knowledge on best practices. Use of JSON, YAML,TOML etc as well.


For Silverblue/toolbox Flatpak development, there’s a lot missing here. If I were just going by your Gemini prompt, I would need to install many other things, like the runtimes and other tools.

I don’t know why I have kept asking it questions. . . Now it has invented flags that do not exist.
--runtime does not exist for

flatpak build-init --runtime=org.freedesktop.Platform build-dir error: Unknown option --runtime=org.freedesktop.Platform

:upside_down_face:

I think I’ll wait for the community now. :crossed_fingers:t5:

1 Like
  1. How are people handling the installations of the runtimes, SDK’s? Assuming they need to be in a toolbox or do they need to be on the Host system as well ?
  2. Would building outside of tooolbox be better? flatpak build-init inside the toolbox?

I build all (Flathub) Flatpaks from inside a toolbox using those aliases for convenience: dotfiles/shell/common.sh at main · travier/dotfiles · GitHub

I also have a script in /usr/local/bin/flatpak that runs flatpak commands outside of the toolbox:

For Fedora Flatpaks, that’s another story and you should reach out to the Fedora Flatpak SIG folks for help.

2 Likes

Keenly watching this thread for suggestions on Silverblue specifically and any workflow improvements, but I’ve created several flatpaks recently that I only published on Github. I only started learning how to build Flatpaks a few months ago, but the YAML syntax is far far easier to write and parse.

It’s worth having a look at docs.flaptak.org which should be a good refresher for you on the current state-of-the-art and stopping by the #flatpak Matrix channel with any specific questions you have the docs don’t answer. They’re very friendly and helpful!

I’m still very much a beginner, so that’s the best I can offer :slight_smile:

1 Like