uninstall: name the configuration and the renamed dotfiles that stay

The closing message no longer lists generic "left in place" items
(*.hm-backup-<time> files that usually don't exist, app data, Flatpak
apps). It says where the configuration stays and how install uses it
again, lists the *.hm-backup-* files Home Manager actually made (if
any), and asks to log out or reboot.
This commit is contained in:
Pierre Kisters committed 2026-10-02 00:00:36 +02:00
1 parent 18c261a0a7
commit 9936f32aea
3 files changed
+40 -13

No files matched your search

+2 -2
View File
@@ -518,8 +518,8 @@ session itself) keep running until you log out or reboot: `uninstall` lists
them and removes Nix without waiting. If Nix's uninstaller fails, the rest
still runs (the `~/.config/home-manager` link goes) except the per-user Nix
state, and the closing message says to reboot and run `uninstall` again.
Your configuration, `*.hm-backup-*` files, app data, Flatpaks and the GitHub
CLI login (`~/.config/gh`) stay.
Your configuration, `*.hm-backup-*` files (the closing message names both),
app data, Flatpaks and the GitHub CLI login (`~/.config/gh`) stay.
To drop steam-frame-nix from a Home Manager configuration you keep, first
run `steam-frame-nix-cleanup --all`, then remove it and switch. Or set Home
+27 -9
View File
@@ -126,6 +126,10 @@ EOF
# --- helpers ----------------------------------------------------------------
tilde() { # path, as ~/... below $HOME
if [[ $1 == "$HOME" || $1 == "$HOME"/* ]]; then printf '%s\n' "~${1#"$HOME"}"; else printf '%s\n' "$1"; fi
}
have_tty() { { : <"$SFN_TTY"; } 2>/dev/null; }
confirm() { # question [default answer: n|y]
@@ -1298,6 +1302,13 @@ remove_path() {
if [[ -e $1 || -L $1 ]]; then rm -rf -- "$1"; info "removed $1"; fi
}
# Files Home Manager renamed out of its way (hm_activate's -b); kept.
hm_backups() {
{ find "$HOME" -maxdepth 4 \( -path "$HOME/.cache" -o -path "$HOME/.var" -o -path "$HOME/.steam" \
-o -path "$HOME/.local/share/Steam" -o -path "$HOME/.local/share/docker" \) -prune \
-o -name '*.hm-backup-*' -print 2>/dev/null || true; } | LC_ALL=C sort
}
remove_leftovers() { # keep_nix
step "Removing per-user leftovers"
local state="${XDG_STATE_HOME:-$HOME/.local/state}"
@@ -1345,6 +1356,11 @@ cmd_uninstall() {
fi
confirm "Continue?" || die "aborted"
# The configuration, for the closing message (its link goes).
local cfg=$DEFAULT_CONFIG_DIR again=install f backups=()
if [[ -L $HM_CONFIG_LINK ]]; then cfg="$(readlink -f "$HM_CONFIG_LINK" || true)"
elif [[ -d $HM_CONFIG_LINK ]]; then cfg=$HM_CONFIG_LINK; fi
load_nix
stop_hm_services
cmd_cleanup --all
@@ -1372,15 +1388,17 @@ cmd_uninstall() {
remove_leftovers "$keep_nix"
step "Done"
cat <<EOF
Intentionally left in place:
- your configuration (e.g. $DEFAULT_CONFIG_DIR, also when cloned)
- files Home Manager renamed to *.hm-backup-<time>
- app data, e.g. ~/.local/share/docker, Firefox profiles, and Flatpak apps
Log out or reboot: running sessions drop the removed tweaks, and programs
that were started from Nix restart without it.
EOF
echo
if [[ -n $cfg && -e $cfg/flake.nix ]]; then
[[ $cfg -ef $DEFAULT_CONFIG_DIR || $cfg -ef $HM_CONFIG_LINK ]] || again="install --flake $(tilde "$cfg")"
echo "Your configuration stays in $(tilde "$cfg") ($again uses it again)."
fi
mapfile -t backups < <(hm_backups)
if (( ${#backups[@]} )); then
echo "Home Manager kept these files it had renamed when it was installed:"
for f in "${backups[@]}"; do printf ' - %s\n' "$(tilde "$f")"; done
fi
echo "Log out or reboot: programs that were started from Nix restart without it."
if (( ${#CLEAN_DEFERRED[@]} || nix_failed )); then
printf '\nNot done yet:\n'
(( ${#CLEAN_DEFERRED[@]} )) && printf ' - %s\n' "${CLEAN_DEFERRED[@]}"
+11 -2
View File
@@ -541,7 +541,7 @@ pkgs.runCommand "cleanup-check" { nativeBuildInputs = [ cleanup pkgs.jq pkgs.git
chmod +x $root/nix-installer
uninst() { # mounted: 1|0
local m=$1
: > $LOG; rm -rf $HOME/.config; mkdir -p $HOME/.config; ln -s $HOME/cfg $HOME/.config/home-manager
: > $LOG; rm -rf $HOME/.config; mkdir -p $HOME/.config; ln -s ''${CFG:-$HOME/cfg} $HOME/.config/home-manager
(STEAM_FRAME_NIX_PROC=$P STEAM_FRAME_NIX_SYSTEM_RUNTIME=$root/run-system; . $INSTALL
ASSUME_YES=1 NIX_INSTALLER_BIN=$root/nix-installer
# sudo without root: systemctl only logged
@@ -556,7 +556,7 @@ pkgs.runCommand "cleanup-check" { nativeBuildInputs = [ cleanup pkgs.jq pkgs.git
res=$(uninst 1) || fail "uninstall failed: $res"
echo "$res"
for p in "zsh (PID 30)" "app (PID 40)" "cwd (PID 41)" "fd (PID 42)" "keep running until you log out or reboot"; do has "$res" "$p"; done
for p in "PID 31" "PID 32" "PID 43" "PID $$" "Not done yet"; do hasnt "$res" "$p"; done
for p in "PID 31" "PID 32" "PID 43" "PID $$" "Not done yet" "Your configuration" "hm-backup" "Flatpak"; do hasnt "$res" "$p"; done
log=$(cat $LOG)
has "$log" "nix-installer uninstall --no-confirm"
has "$log" "LazyUnmount=yes" # the drop-in was there while it ran
@@ -573,6 +573,15 @@ pkgs.runCommand "cleanup-check" { nativeBuildInputs = [ cleanup pkgs.jq pkgs.git
res=$(RC=term uninst 1) && fail "interrupted uninstall succeeded: $res"
has "$(cat $LOG)" "LazyUnmount=yes"
gone $D
# the closing message: the configuration and the files Home Manager renamed
mkdir -p $HOME/cfg $HOME/nix-config $HOME/.cache; touch $HOME/cfg/flake.nix $HOME/nix-config/flake.nix
touch $HOME/.bashrc.hm-backup-20260101-000000 $HOME/.cache/x.hm-backup-20260101-000000
res=$(uninst 0) || fail "uninstall failed: $res"
has "$res" "Your configuration stays in ~/cfg (install --flake ~/cfg uses it again)."
has "$res" "Home Manager kept these files it had renamed when it was installed:"
has "$res" " - ~/.bashrc.hm-backup-20260101-000000"; hasnt "$res" "x.hm-backup"
res=$(CFG=$HOME/nix-config uninst 0) || fail "uninstall failed: $res"
has "$res" "Your configuration stays in ~/nix-config (install uses it again)."
SH
echo "H ok"
touch $out