Skip to content

Commit

Permalink
installer: specify origin when updating flatpakref (#107)
Browse files Browse the repository at this point in the history
When updating an application installed via flatpakref,
specify the origin to the generated flatpak install
command.
  • Loading branch information
gmodena authored Dec 3, 2024
1 parent 01ca2cb commit 2880dc4
Showing 1 changed file with 5 additions and 4 deletions.
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 2880dc4

Please sign in to comment.