Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

installer: forcefully delete remotes when managing state. #86

Merged
merged 1 commit into from
Oct 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions modules/installer.nix
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,16 @@ let
'';
flatpakAddRemote = installation: remotes: map (flatpakAddRemotesCmd installation) remotes;

flatpakDeleteRemotesCmd = installation: {}: ''
flatpakDeleteRemotesCmd = installation: uninstallUnmanagedState: {}: ''
# Delete all remotes that are present in the old state but not the new one
# $OLD_STATE and $NEW_STATE are globals, declared in the output of pkgs.writeShellScript.
# If uninstallUnmanagedState is true, then the remotes will be deleted forcefully.
${pkgs.jq}/bin/jq -r -n \
--argjson old "$OLD_STATE" \
--argjson new "$NEW_STATE" \
'(($old.remotes // []) - ($new.remotes // []))[]' \
| while read -r REMOTE_NAME; do
${pkgs.flatpak}/bin/flatpak remote-delete --${installation} $REMOTE_NAME
${pkgs.flatpak}/bin/flatpak remote-delete ${if uninstallUnmanagedState then " --force " else " " } --${installation} $REMOTE_NAME
done
'';

Expand Down Expand Up @@ -215,7 +216,7 @@ pkgs.writeShellScript "flatpak-managed-install" ''

# Uninstall remotes that have been removed from services.flatpak.packages
# since the previous activation.
${flatpakDeleteRemotesCmd installation {}}
${flatpakDeleteRemotesCmd installation uninstallUnmanagedState {}}

# Install packages
${mkFlatpakInstallCmd installation updateApplications cfg.packages}
Expand Down
Loading