flatpak-compose

Define your flatpak applications and permissions

MIT License

Stars
7

Flatpak Compose

This project works in most of the cases but it has not been thoroughly tested. Therefore, issues may arise. Your feedback and bug reports are highly appreciated as they help us improve the project.

Features

  • Manage Repositories: Add or remove Flatpak repositories.
  • Manage Applications: Install, uninstall, and update Flatpak applications.
  • Permission Overrides: Set or replace permissions (overrides) for installed applications.

Installation

Mac

# Download the latest release for Mac
curl -LO https://github.com/faan11/flatpak-compose/releases/latest/download/flatpak-compose-macos-amd64.zip

# Unzip the downloaded file
unzip flatpak-compose-macos-amd64.zip

# Make the binary executable
chmod +x flatpak-compose-macos-amd64

# Move the binary to a directory in your PATH (optional)
sudo mv flatpak-compose-macos-amd64 /usr/local/bin/flatpak-compose

Windows

  1. Open your web browser and go to the Releases page of your repository.
  2. Download the flatpak-compose-windows-amd64.zip file from the latest release.
  3. Extract the downloaded ZIP file.
  4. You'll find the flatpak-compose-windows-amd64.exe binary inside the extracted folder.

Linux

# Download the latest release for Linux
curl -LO https://github.com/faan11/flatpak-compose/releases/latest/download/flatpak-compose-linux-amd64.zip

# Unpack the downloaded file
unzip flatpak-compose-linux-amd64.zip

# Make the binary executable
chmod +x flatpak-compose-linux-amd64

# Move the binary to a directory in your PATH (optional)
sudo mv flatpak-compose-linux-amd64 /usr/local/bin/flatpak-compose

These commands will download the latest release binary for each platform, extract the contents, make the binary executable, and optionally move it to a directory in your PATH for easier access. Adjust the downloaded file name and paths as needed.

Build

  1. Clone the repository.
  2. Build the application using go build.
  3. Optionally, set the generated binary in your system PATH.

Usage

Getting started

You can start from scratch or export the system state and generate the system flatpak-compose.yaml

flatpak-compose export-state system > flatpak-compose.yaml

Now you can change your flatpak-compose.yaml as you deside. After changing the file, you can proceed by seeing which command will be applied ( plan ) or directly apply the changes ( using the apply command ).

Examples

# flatpak repositories
envs:
- core:
    min-free-space-size: 500MB
    mode: bare-user-only
    repo_version: "1"
    xa.pinned: runtime/org.freedesktop.Sdk/x86_64/23.08;runtime/org.gtk.Gtk3the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qiqV3AohBMhnQbGzyHf2+drutIaoh7Rj80XRh2bkkuPLwlNPf+bTXwNVGse4bej7B3oV6Ae1N7lTNVF4Qh+1OowtGjmfJPWo0z1s6HFJVxoIof9z58Msvgao0zrKGqaMWaNQ6LUeC9g9Aj/9Uqjbo8X54aLiYs8Z1WNc06jKP+gv8AWLtv6CR+l2kLez1YMDucjm7v6iuCMVAmZdmxhg5I/X2+OM3vBsqPDdQpr2TPDLX3rCrSBiS0gOQ6DwN5N5QeTkxmY/7QO8bgLo/Wzu1iilH4vMKW6LBKCaRx5UEJxKpL4wkgITsYKneIt3NTHo5EOuaYk+y2+Dvt6EQFiuMsdbfUjs3seIHsghX/cbPJa4YUqZAL8C4OtVHaijwGo0ymt9MWvS9yNKMyT0JhN2/BdeOVWrHk7wXXJn/ZjpXilicXKPx4udCF76meE+6N2u/T+RYZ7fP1QMEtNZNmYDOfA6sViuPDfQSHLNbauJBo/n1sRYAsL5mcG22UDchJrlKvmK3EOADCQg+myrm8006LltubNB4wWNzHDJ0Ls2JGzQZCd/xGyVmUiidCBUrD537WdknOYE4FD7P0cHaM9brKJ/M8LkEH0zUlo73bY4XagbnCqve6PvQb5G2Z55qhWphd6f4B6DGed86zJEa/RhSsAYAA2dwZwA=
      gpg-verify: "true"
      gpg-verify-summary: "true"
      url: https://dl.flathub.org/repo/
      xa.comment: Central repository of Flatpak applications
      xa.description: Central repository of Flatpak applications
      xa.homepage: https://flathub.org/
      xa.icon: https://dl.flathub.org/repo/logo.svg
      xa.title: Flathub


# application list
applications:
# keepass app
- name: org.keepassxc.KeePassXC
  repo: flathub
  branch: stable
  overrides: []
  overrides_user: []
  type: system
# firefox app
- name: org.mozilla.firefox
  repo: flathub
  branch: stable
  overrides:
  - --nofilesystem=host
  - --nosocket=x11
  - --socket=fallback-x11
  - --allow=bluetooth
  overrides_user: []
  type: system 

Commands

Apply Changes

Apply changes specified in a YAML file.

flatpak-compose apply [-f file.yaml] [-current-state=system-compose/system]

Default file: flatpak-compose.yaml / flatpak-compose.yml

Plan Changes (Print Only)

Print the commands without applying changes.

flatpak-compose plan [-f file.yaml] [-current-state=system-compose/system]

Default file: flatpak-compose.yaml / flatpak-compose.yml

Export System State

Print the current system state in a YAML file.

flatpak-compose export-state system
flatpak-compose export-state system-compose

The export-state will add a new field "all" for each application. This field holds all the permissions (default and static permissions).

Help

Show usage information.

flatpak-compose help

States Explanation

  • Current State: Can be the System State or the System Compose state.
  • Desired State: The desired state (or Compose State) is the yaml file. Contains applications/repos specified in the YAML file.

Flatpak compose brings the system from the current state to the desired state.

  • System State: Includes all applications/repos installed in the system.
  • System-Compose State: Applications/repos common between the compose and system states (right join).

Help

Show usage information.

flatpak-compose help

File Structure

  • internal/model/: Contains the state definition
  • internal/state/: Contains logic for getting the current and next states, as well as diffing them.
  • internal/utility/: Contains functions used by the state module to read permissions and the environment from the system.
  • internal/view/: Handles generating commands and executing them.

How It Works

The application reads a YAML file describing Flatpak configurations and applies the specified changes to the system.

Assets

The logo image is taken by Flaticon.com.

Contributing

Contributions are welcome! Feel free to open issues or pull requests for enhancements, bug fixes, or new features.

License

This project is licensed under the [MIT] - see the LICENSE file for details.