Skip to content

WIP: overrides: read base config from files.#162

Draft
gmodena wants to merge 3 commits intomainfrom
82-add-the-ability-to-specify-an-overrides-file-directory
Draft

WIP: overrides: read base config from files.#162
gmodena wants to merge 3 commits intomainfrom
82-add-the-ability-to-specify-an-overrides-file-directory

Conversation

@gmodena
Copy link
Owner

@gmodena gmodena commented Jun 29, 2025

WARNING: this PR contains experimental code. It overwrites system/user flatpak override files and could cause data loss.

Addresses #82 , #128.

What

This PR introduces the capability to read overrides from user provided config files, and perform a three way merge with config.flatpak.overrides and the active state config.

Why

From #82:

[...] I have a number of Flatpak override config files already present on my device. It would be very useful if I could simply drop them in a folder as part of my OS config. This would also allow users to use tools they are already familiar with, when configuring Flatpak overrides, e.g. flatseal, and the built in configuration tool present on KDE. [...]

How

The overrides config has been refactored with two new options:

  • settings: an attribute set of override settings
  • files: a list of paths to ini Flatpak overrides files. The files will be merged with the settings attribute set.

At activation nix-flatpak will merge override configurations from multiple sources:

  • base: base configuration from override files (config.flatpak.overrides.files).
  • active: currently active overrides (existing state. e.g. $HOME/.local/share/flatpak/overrides).
  • old_state: previous declarative state (e.g. $HOME/.local/state/home-manager/gcroots/flatpak-state.json).
  • new_state: new declarative state (e.g. config.flatpak.overrides.settings).

For each entry, the merge formula is:

base + (active - old) + new

Example

  services.flatpak.overrides.settings =  {
   global = {
     # Force Wayland by default
     Context.sockets = ["wayland" "!x11" "!fallback-x11"];

     Environment = {
       # Fix un-themed cursor in some Wayland apps
       XCURSOR_PATH = "/run/host/user-share/icons:/run/host/share/icons";

       # Force correct theme for some GTK apps
       GTK_THEME = "Adwaita:dark";
     };
   };

   "com.visualstudio.code".Context = {
     filesystems = [
       "xdg-config/git:ro" # Expose user Git config
       "/run/current-system/sw/bin:ro" # Expose NixOS managed software
     ];
     sockets = [
       "gpg-agent" # Expose GPG agent
       "pcsc" # Expose smart cards (i.e. YubiKey)
     ];
   };
 };

 services.flatpak.overrides.files = [
   "/home/gmodena/config/overrides/org.onlyoffice.desktopeditors"
   "/home/gmodena/config/overrides/org.gnome.gedit"
   "/home/gmodena/config/overrides/global"
 ];

Known issues

  • [] overrides ini files generate by nix-flatpak contains an extra newline
  • [] ...

Read overrides from user provided config files,
and perform a three way merge with `config.flatpak.overrides`
and active state config.
Refactor flatpak.overrides to include two attributes:
- settings: an attribute set of override settings
- files: a list of paths to ini Flatpak overrides files.
  The files will be merged with the settings attribute set.
Bump to reflect `overrides` changes.
@gmodena gmodena force-pushed the 82-add-the-ability-to-specify-an-overrides-file-directory branch from c040480 to 8421a37 Compare January 11, 2026 08:30
@gmodena gmodena changed the title overrides: read base config from files. WIP: overrides: read base config from files. Jan 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add the ability to specify an overrides file directory.

1 participant