Uninstall: wait until nothing uses /nix before removing Nix

nix-installer uninstall failed at `systemctl stop nix.mount` ("Job
failed") while programs started from the Nix store still ran: a terminal
session's tools, or apps that mapped Home Manager's mime.cache.

- Before nix-installer runs, after Home Manager is gone, uninstall scans
  /proc for the user's processes whose exe, cwd, root, an fd or a mapped
  file is in /nix, and lists them by name and PID (the shells it was
  started from included; itself, its subshells and its curl | bash
  pipeline skipped). Close them and press Enter to re-check, or abort;
  with --yes or without a terminal it stops: "close these or reboot, then
  run uninstall again". Nothing is killed (replaces the old kill prompt).
- nix-installer runs from a copy outside /nix.
- cleanup check H: a fake /proc (STEAM_FRAME_NIX_PROC) with programs from
  the store stops before Nix; without them Nix is removed.
This commit is contained in:
Pierre Kisters committed 2026-10-01 18:14:19 +02:00
1 parent da01b7e5ac
commit 3acacc6388
5 files changed
+153 -47

No files matched your search

+4 -2
View File
@@ -501,8 +501,10 @@ stops Home Manager's user services (reverting the UI patches), runs
`cleanup --all`, runs `home-manager uninstall`, then removes Nix and the
per-user Nix state (see [Set up by install.sh](#set-up-by-installsh)). If
SteamVR is running, its key is restored when SteamVR stops (the closing
message says so). If Nix's own uninstaller fails (e.g. something still uses
`/nix`), the rest still runs (the `~/.config/home-manager` link goes) except
message says so). Programs started from the Nix store keep `/nix` busy:
before removing Nix, `uninstall` lists them and waits until you close them
(with `--yes`, it stops instead); close them or run it right after a reboot.
If Nix's own uninstaller fails anyway, 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 and
Flatpaks stay.