tinywrkb / flatpaks

57 stars 13 forks source link

flatpaks

A few Flatpaks that I hastly packaged. These are not thoroughly tested so use at your own discretion.
Packaging was adapted mainly from Arch Linux's official PKGBUILDs and the AUR.
Most of these are PoC, not maintained, might need some cleanup, missing a feature here and there, and in general are not ready to publish via Flathub.
The catalyst for packaging these apps is to prove that it's possible to convert to, and as a precondition for switching to an immutable system, an OS that has a clear seperation between the stateless read-only distributed OS files, and the stateful data and configs.

How to build

  1. Install flatpak-builder
  2. Clone the flatpaks repo
    git clone https://github.com/tinywrkb/flatpaks.git
    git submodule init
    git submodule update
  3. Create a working folder for flatpak-builder somewhere
    mkdir build
  4. Build the package with flatpak-builder and install it as a user Flatpak app. Replace manifest.yaml with the path to application manifest.
    flatpak-builder --install --user --force-clean \
    --state-dir=build/flatpak-builder \
    --repo=build/flatpak-repo build/flatpak-target \
    manifest.yaml

Tips and tricks

Font packages

Flatpak does not support font packages or extensions. In order for Flatpak and host apps to use fonts installed as Flatpak package we need a few workarounds.

  1. Give all our Flatpak apps access to the user's fontconfig configuration file, and also the font package installed path.
    Due to a mismatch of XDG_CONFIG_DIR value between the host and the Flatpak sandbox (a different path for each app), we need to set some environment variables.
    Also note that the fontconfig variable value need to be an absolute path, meaning it needs to be expanded before given to the flatpak override command.
    $ flatpak override --user \
    --filesystem=~/.config/fontconfig:ro \
    --filesystem=~/.local/share/flatpak:ro \
    --filesystem=/var/lib/flatpak:ro \
    --env=FONTCONFIG_FILE=$XDG_CONFIG_HOME/fontconfig/fonts.conf

If your fontconfig folder is in dotfiles, then apps that use the --persist=. permission (e.g. Steam) will fail to start after a first seccessful run and will output the following error message.

bwrap: Can't make symlink at /home/USER/.config/fontconfig: File exists

The workaround for this issue is to create first a ~/.config/fontconfig folder before creating the dotfiles symlinks, so the folder will be bind mounted into the container instead of having flatpak try creating a ~/.config/fontconfig symlink on each run.
This workaround requires adding a filesystem access permission to the dotfiles folder.

$ flatpak override --user \
    --filesystem=~/.dotfiles/fontconfig/.config/fontconfig:ro
  1. Adding the following to $XDG_CONFIG_HOME/fontconfig/fonts.conf will tell fontconfig to include the Flatpak font package in its scan.
    The first directive is required because fc-cache omits the default font locations when scanning inside a Flatpak sandbox, and that's due to our use of FONTCONFIG_FILE variable.
    Note that you need to replace {FontName} with the name of the font as defined in the Flatpak app ID, see for example the Noto fonts packages.
<include ignore_missing="yes">/etc/fonts/fonts.conf</include>

<dir prefix="default">.local/share/flatpak/app/org.freedesktop.Platform.Fonts.{FontName}/current/active/files/share/fonts</dir>
<dir>/var/lib/flatpak/app/org.freedesktop.Platform.Fonts.{FontName}/current/active/files/share/fonts</dir>
<include prefix="default" ignore_missing="yes">.local/share/flatpak/app/org.freedesktop.Platform.Fonts.{FontName}/current/active/files/share/fonts/conf.d</include>
<include ignore_missing="yes">/var/lib/flatpak/app/org.freedesktop.Platform.Fonts.{FontName}/current/active/files/share/fonts/conf.d</include>
  1. You can also set FONTCONFIG_PATH, but make sure that your user's fonts.conf is including the system's conf.d folder, as fontconfig might not find the system's conf.d if it was set as a relative path in the system's fonts.conf.

    $ flatpak override --user \
    --env=FONTCONFIG_PATH=$XDG_CONFIG_HOME/fontconfig

    Add the include element to your user's fonts.conf.

    <include ignore_missing="yes">/etc/fonts/conf.d</include>
  2. Now we can update the host's font cache.

cd ~
fc-cache
  1. To update the font cache of a Flatpak app sandbox just restart the app.
Fontconfig related bugs

extra-data caching and avoiding download

Copy the extra-data source into FLATAPK_INSTALLATION_PATH/extra-data/CHECKSUM/FILENAME.

Terminal emulators: host access

List of applications

Container and virtualization

Development

Development/Binary analysis

Development/Binary analysis/Assembler & disassemblers
Development/Binary analysis/ELF
Development/Binary analysis/Hex editors & viewers
Development/Binary analysis/Firmware
Development/Binary analysis/PE

Development/Database

Development/Debugging

Development/Flatpak

Development/Kernel

Development/Markup & data serialization

Development/Python

Development/VCS

Display server

Display server/Remoting and screen sharing

Display server/Screen config managers

Display server/Shell

Display server/X11

Documents

Documents/Journaling

Documents/Notetaking

Documents/Office suites and editors

Documents/PDF tools

Documents/Text editors

Documents/Viewers

Electronics

Electronics/Analog circuit simulation

Electronics/Digital logic

Electronics/Embedded

Electronics/HDL

Electronics/Printed circuit board design

Electronics/Signals

Electronics/Signals/Instrumentation
Science/Electronics/Signals/SDR

Engineering

Engineering/CAD

Engineering/Calculators and unit converters

Games

Files

Files/Mobile devices

Files/File managers

Files/Archiving and compression tools

Files/Duplicates cleaners

Fonts

Fonts/Tools

Internet

Internet/Communication

Internet/File sharing

Internet/File sharing/BitTorrent
Internet/File sharing/Cloud sync

Internet/Media downloaders

Internet/URL watcher

Internet/Web browsers

Math

Math/Algebra

Multimedia

Multimedia/Codecs

Multimedia/Icons

Multimedia/Image

Multimedia/Image/Screenshot

Multimedia/Audio

Multimedia/Video

Network

Network/Diagnostics

Network/Network managers

Security

Security/2FA, passwords & keys

Security/Analysis & pentesting

System

System/Benchmarking & diagnostics

Terminal

Terminal/Session tools

Terminal/Text terminal emulators

Terminal/Video terminal emulators

Utilities

Utilities/Calendar and date

Utilities/Translation

Utilities/Typing