Skip to content

Commit

Permalink
Merge branch 'main' into add-latest-tag
Browse files Browse the repository at this point in the history
  • Loading branch information
gmodena authored Dec 13, 2024
2 parents 99d3c60 + 010634f commit c100dbe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ talk at NixCon 2023.
`nix-flatpak` follows a [convergent mode](https://flyingcircus.io/blog/thoughts-on-systems-management-methods/) approach to package management (described in [this thread](https://discourse.nixos.org/t/feature-discussion-declarative-flatpak-configuration/26767/2)):
the target system state description is not exhaustive, and there's room for divergence across builds
and rollbacks.
For a number of desktop application I want to be able to track the latest version, or allow them to auto update.
For a number of desktop applications I want to be able to track the latest version, or allow them to auto update.
For such applications, a convergent approach is a reasonable tradeoff wrt system reproducibility. YMMV.

Flatpak applications are installed by systemd oneshot service triggered at system activation. Depending on
Expand All @@ -30,7 +30,7 @@ Releases are tagged with [semantic versioning](https://semver.org/). Versions be
Users can track a version by passing its tag as `ref`
```nix
...
nix-flatpak.url = "github:gmodena/nix-flatpak/?ref=v0.5.0";
nix-flatpak.url = "github:gmodena/nix-flatpak/?ref=v0.5.1";
...
```

Expand Down Expand Up @@ -215,7 +215,7 @@ Package overrides can be declared via `services.flatpak.overrides`. Following is

A couple of things to be aware of when working with `nix-flatpak`.

## Infinte recusion in home-manager imports
## Infinite recursion in home-manager imports

Users have reported an infinite recursion stacktrace when importing an home-manager module outside of where home-manager
itself was imported.
Expand Down
9 changes: 5 additions & 4 deletions modules/installer.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,17 @@ let
{ }
(builtins.filter (package: utils.isFlatpakref package) cfg.packages);

# Get the appId from the flatpakref file or the flatpakref URL to pass to flatpak commands.
# Get the appId and origin from a flatpakref file or URL to pass to flatpak commands.
# As of 2024-10 Flatpak will fail to reinstall from flatpakref URL (https://github.com/flatpak/flatpak/issues/5460).
# This function will return the appId if the package is already installed, otherwise it will return the flatpakref URL.
getAppIdOrRef = flatpakrefUrl: installation:
installOrUpdateFromFlatpakref = flatpakrefUrl: installation:
let
appId = flatpakrefCache.${(utils.sanitizeUrl flatpakrefUrl)}.Name;
origin = utils.getRemoteNameFromFlatpakref null flatpakrefCache.${(utils.sanitizeUrl flatpakrefUrl)};
in
''
$(if ${pkgs.flatpak}/bin/flatpak --${installation} list --app --columns=application | ${pkgs.gnugrep}/bin/grep -q ${appId}; then
echo "${appId}"
echo "${origin} ${appId}"
else
echo "--from ${flatpakrefUrl}"
fi)
Expand Down Expand Up @@ -153,7 +154,7 @@ let
flatpakCmdBuilder installation " install "
(if update then " --or-update " else " ") +
(if utils.isFlatpakref { flatpakref = flatpakref; }
then getAppIdOrRef flatpakref installation # If the appId is a flatpakref URL, get the appId from the flatpakref file
then installOrUpdateFromFlatpakref flatpakref installation # If the appId is a flatpakref URL, extract the appId and origin from the flatpakref.
else " ${origin} ${appId} ");

updateCmdBuilder = installation: commit: appId:
Expand Down

0 comments on commit c100dbe

Please sign in to comment.