From 2880dc44fc8c450b4ffe1609a4bccd19ef759f5c Mon Sep 17 00:00:00 2001 From: Gabriele Modena Date: Tue, 3 Dec 2024 13:25:54 +0100 Subject: [PATCH] installer: specify origin when updating flatpakref (#107) When updating an application installed via flatpakref, specify the origin to the generated flatpak install command. --- modules/installer.nix | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/installer.nix b/modules/installer.nix index 5632afc..41db816 100644 --- a/modules/installer.nix +++ b/modules/installer.nix @@ -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) @@ -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: