diff --git a/README.md b/README.md index 85cd543..836fc17 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/install.sh b/install.sh index 9034d46..bdba2e8 100755 --- a/install.sh +++ b/install.sh @@ -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 < - - 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[@]}" diff --git a/modules/cleanup/check.nix b/modules/cleanup/check.nix index 4fa7f68..0ae242a 100644 --- a/modules/cleanup/check.nix +++ b/modules/cleanup/check.nix @@ -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