GitPedia

Declarative flatpak

Declaratively manage Flatpak installations in NixOS and your $HOME

From in-a-dil-emma·Updated June 6, 2026·View on GitHub·

Declaratively manage Flatpak installations in NixOS and your $HOME The project is written primarily in Nix, distributed under the GNU General Public License v3.0 license, first published in 2023. Key topics include: declarative-flatpak, flatpak, home-manager, home-manager-module, nix.

Declarative flatpaks

Declaratively manage Flatpak installations in NixOS and your $HOME

[!IMPORTANT]
The setup script performs changes in a transaction.
Errors cause the transaction to fail immediately.
Only successful transactions get applied.
Therefore, it may take a while until your changes take effect!

[!WARNING]
The home-manager module assumes that flatpak is usable on your system.
If this is not the case, do not bug report.

[!CAUTION]
Expect at least a 2x storage usage increase.
This module attempts to optimize storage space use through reflinks, these require a filesystem capable of Copy-on-Write.

Also try https://github.com/gmodena/nix-flatpak

Versioning

Releases are done through git tags.

Setup

Inputs

<details open> <summary> Flakes </summary>

flake.nix

nix
{ inputs = { flatpaks.url = "github:in-a-dil-emma/declarative-flatpak/latest"; }; }
</details> <details open> <summary> npins </summary>

console

console
$ npins add github --name flatpaks in-a-dil-emma declarative-flatpak
</details>

Import in NixOS

<details open> <summary> Flakes </summary>

configuration.nix

nix
{ flatpaks, ... }: { imports = [ flatpaks.nixosModules.default ]; }
</details> <details open> <summary> npins </summary>

configuration.nix

nix
{ flatpaks, ... }: { imports = [ (flatpaks + "/nixos") ]; }
</details>

Import in Home Manager (standalone or as a NixOS module)

<details open> <summary> Flakes </summary>

home.nix

nix
{ flatpaks, ... }: { imports = [ flatpaks.homeModules.default ]; }
</details> <details open> <summary> npins </summary>

home.nix

nix
{ flatpaks, ... }: { imports = [ (flatpaks + "/home-manager") ]; }
</details>

Configuring

<details> <summary>services → <b>flatpak</b></summary>
OPTIONTYPEDEFAULT
enablebooleanfalse
preRemotesCommandstring or nullnull
preInstallCommandstring or nullnull
preSwitchCommandstring or nullnull
UNCHECKEDfinalizeCommandstring or nullnull
flatpakDirpath or nullNixOS: /var/lib/flatpak ; <br>Home-Manager: ${XDG_DATA_HOME}/flatpak
forceRunOnActivationbooleanfalse
onCalendarsystemd timeweekly

Caution:

UNCHECKEDfinalizeCommand will not cause the transaction to fail.
This hook should only be used for commands you don't care about failing.

</details> <details> <summary>... → packages → <b><ins>list element</ins></b></summary>

<ins>list element</ins> is a string, matching one of the following patterns:

  • {remote}:{type}/{ref}/[{arch}]/{branch}[:{commit}]
  • {remote}:{path}.flatpakref
  • :{path}.flatpak

Expressions in [angle brackets] may be omitted.
Expressions in {curly brackets} must be substituted.

KEYSUBSTITUTION DESCRIPTION
remoteThe remote to fetch from.
typeRef type. Either app or runtime.
refRef ID used by flatpak.
archSystem architecture, in flatpak's format.
branchRef release branch.
commitUpdate to commit. Must be exactly 64 characters long.
pathA path that exists.
</details> <details> <summary>... → remotes → <b><ins>key-value pair</ins></b></summary>
KEYVALUE
NameURL
</details> <details> <summary>... → overrides → <b><ins>key-value pair</ins></b></summary>
KEYVALUE
FilenameSee https://docs.flatpak.org/en/latest/flatpak-command-reference.html#flatpak-metadata
</details> <details> <summary>Example configuration.</summary>
nix
{ services.flatpak = { enable = true; remotes = { "flathub" = "https://dl.flathub.org/repo/flathub.flatpakrepo"; "flathub-beta" = "https://dl.flathub.org/beta-repo/flathub-beta.flatpakrepo"; }; packages = [ "flathub:app/org.kde.index//stable" "flathub-beta:app/org.kde.kdenlive/x86_64/stable" ":${./foobar.flatpak}" "flathub:/root/testflatpak.flatpakref" ]; overrides = { # note: "global" is a flatpak thing # if you ever ran "flatpak override" without specifying a ref you will know "global".Context = { filesystems = [ "home" ]; sockets = [ "!x11" "!fallback-x11" ]; }; "org.mozilla.Firefox" = { Environment = { "MOZ_ENABLE_WAYLAND" = 1; }; Context.sockets = [ "!wayland" "!fallback-x11" "x11" ]; }; }; }; }
</details>

Please consult the module options for more information.

Contributors

Showing top 6 contributors by commit count.

View all contributors on GitHub →

This article is auto-generated from in-a-dil-emma/declarative-flatpak via the GitHub API.Last fetched: 6/15/2026