install: use an existing ~/nix-config instead of stopping

Without ~/.config/home-manager and --flake, a flake in ~/nix-config
(e.g. left by uninstall) is used as it is, like --flake ~/nix-config,
and linked to ~/.config/home-manager. A directory there without
flake.nix still stops the install.
This commit is contained in:
Pierre Kisters committed 2026-10-02 00:01:56 +02:00
1 parent 569ebea6cd
commit d9773fafc4
3 files changed
+28 -11

No files matched your search

+8 -7
View File
@@ -79,13 +79,14 @@ on `main`. `sudo` needs a password: run `passwd` first if you never set one.
The installer installs Nix (skipped if Nix already works), uses
`~/.config/home-manager` or `--flake <dir-or-flakeref>` (if there is none, it
creates `~/nix-config` from the [template](template) with your user name) and
runs `home-manager switch`; what it sets up is listed under
[Set up by install.sh](#set-up-by-installsh). Everything works in the running
session right away, except two settings read only at a process start: the
[keyboard layout](docs/session.md#keyboard-layout) (next Steam session start)
and the [SteamVR dashboard patches](docs/steamvr-debugger.md) (VR pet, VR
keyboard suggestions, window curvature, ...; next SteamVR start). If they
uses `~/nix-config` as it is, or creates it from the [template](template)
with your user name) and runs `home-manager switch`; what it sets up is
listed under [Set up by install.sh](#set-up-by-installsh). Everything works
in the running session right away, except two settings read only at a
process start: the [keyboard layout](docs/session.md#keyboard-layout) (next
Steam session start) and the
[SteamVR dashboard patches](docs/steamvr-debugger.md) (VR pet, VR keyboard
suggestions, window curvature, ...; next SteamVR start). If they
are waiting, the installer ends with "Restart once": reboot once. Re-running
it just switches again (`--yes` answers every question). Afterwards edit
`~/nix-config/home.nix` and switch (see [Usage](#usage)).
+6 -4
View File
@@ -69,7 +69,8 @@ Commands:
if the clone fails. Only a missing directory or
the unchanged template is replaced by the clone;
anything else there is used as it is
otherwise ~/.config/home-manager
otherwise ~/.config/home-manager, else the flake in
~/nix-config (linked there)
neither exists a new config in ~/nix-config from the
steam-frame-nix template, linked to
~/.config/home-manager
@@ -353,9 +354,6 @@ template_untouched() { # dir
create_config() { # dir [question]
local dir=$1 system
if [[ -e $dir ]] && [[ -n $(ls -A "$dir" 2>/dev/null) ]]; then
if [[ -e $dir/flake.nix ]]; then
die "$dir already contains a flake. Use it with: install.sh install --flake $dir"
fi
die "$dir exists and is not empty; move it away or pass --flake <your config>"
fi
[[ $USER_NAME =~ ^[a-z_][a-z0-9_-]*$ ]] || die "unsupported user name '$USER_NAME' for the template"
@@ -529,6 +527,10 @@ cmd_install() {
fi
step "Finding the Home Manager configuration"
if [[ -z $flake && ! -e $HM_CONFIG_LINK && ! -L $HM_CONFIG_LINK && -e $DEFAULT_CONFIG_DIR/flake.nix ]]; then
info "$DEFAULT_CONFIG_DIR already exists: using it as it is"
flake=$DEFAULT_CONFIG_DIR
fi
if [[ -n $flake ]]; then
if [[ -d ${flake%%#*} ]]; then
dir="$(cd "${flake%%#*}" && pwd -P)"
+14
View File
@@ -509,6 +509,20 @@ pkgs.runCommand "cleanup-check" { nativeBuildInputs = [ cleanup pkgs.jq pkgs.git
! grep -q "^clone" $LOG || fail "cloned again"
! switched_to_template || fail "template switched again"
[ "$(grep -c '^hm ' $LOG)" = 1 ] || fail "switches: $(cat $LOG)"
# a plain install with ~/nix-config but no link: used as it is, linked
rm $HOME/.config/home-manager
res=$(inst)
has "$res" "$HOME/nix-config already exists: using it as it is"
hasnt "$res" "Creating a Home Manager configuration"
has "$res" "hm switch --flake $HOME/nix-config -b"
has "$res" "'home-manager switch' (from"
[ "$(readlink $HOME/.config/home-manager)" = $HOME/nix-config ] || fail "plain install: link"
# not a flake: the error, nothing created
rm $HOME/.config/home-manager $HOME/nix-config/flake.nix
res=$(inst 2>&1) && fail "a directory without flake.nix accepted"
has "$res" "$HOME/nix-config exists and is not empty"
gone $HOME/.config/home-manager
echo "G ok"
# --- H: uninstall: Nix goes while programs from the store still run ---