Skip to content

Commit

Permalink
installer: don't uninstall on empty OLD_STATE.
Browse files Browse the repository at this point in the history
Check that OLD_STATE has been populated
before attempting to diff it with NEW_STATE
to determine what packages to uninstall.
  • Loading branch information
gmodena committed Jan 23, 2024
1 parent bb339db commit 812db7c
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions modules/installer.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,16 @@ let

flatpakUninstallCmd = installation: {}: ''
# Uninstall all packages that are present in the old state but not the new one
${pkgs.jq}/bin/jq -r -n \
--argjson old "$OLD_STATE" \
--argjson new "$NEW_STATE" \
'($old.packages - $new.packages)[]' \
# $OLD_STATE and $NEW_STATE are globals, declared in the output of pkgs.writeShellScript.
if [ "$OLD_STATE" != "{}" ]; then
${pkgs.jq}/bin/jq -r -n \
--argjson old "$OLD_STATE" \
--argjson new "$NEW_STATE" \
'($old.packages - $new.packages)[]' \
| while read -r APP_ID; do
${pkgs.flatpak}/bin/flatpak uninstall --${installation} -y $APP_ID
done
done
fi
'';

flatpakInstallCmd = installation: update: { appId, origin ? "flathub", commit ? null, ... }: ''
Expand Down

0 comments on commit 812db7c

Please sign in to comment.