diff --git a/README.md b/README.md index 836fc17..45e21fc 100644 --- a/README.md +++ b/README.md @@ -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 ` (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)). diff --git a/install.sh b/install.sh index 057c75f..8c1582d 100755 --- a/install.sh +++ b/install.sh @@ -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 " 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)" diff --git a/modules/cleanup/check.nix b/modules/cleanup/check.nix index 3ff39fc..07e99cd 100644 --- a/modules/cleanup/check.nix +++ b/modules/cleanup/check.nix @@ -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 ---