Check if NIX_LINK_NEW exists instead of checking that NIX_LINK doesn't exist

For brand new installations, neither NIX_LINK_NEW
(`$XDG_STATE_HOME/nix/profile` or `~/.local/state/nix/profile`), nor
NIX_LINK (`~/.nix-profile`) will exist.

This restores functionality to nix-env, which is relied upon by GitHub
Actions such as https://github.com/cachix/cachix-action and the Nixpkgs
EditorConfig (and other) CI.
This commit is contained in:
Cole Helbling 2023-02-28 16:10:42 -08:00
parent 4489def1b3
commit 2b801d6e3c
2 changed files with 2 additions and 2 deletions

View file

@ -8,7 +8,7 @@ if [ -n "$XDG_STATE_HOME" ]; then
else else
NIX_LINK_NEW=$HOME/.local/state/nix/profile NIX_LINK_NEW=$HOME/.local/state/nix/profile
fi fi
if ! [ -e "$NIX_LINK" ]; then if [ -e "$NIX_LINK_NEW" ]; then
NIX_LINK="$NIX_LINK_NEW" NIX_LINK="$NIX_LINK_NEW"
else else
if [ -t 2 ] && [ -e "$NIX_LINK_NEW" ]; then if [ -t 2 ] && [ -e "$NIX_LINK_NEW" ]; then

View file

@ -8,7 +8,7 @@ if [ -n "$HOME" ] && [ -n "$USER" ]; then
else else
NIX_LINK_NEW="$HOME/.local/state/nix/profile" NIX_LINK_NEW="$HOME/.local/state/nix/profile"
fi fi
if ! [ -e "$NIX_LINK" ]; then if [ -e "$NIX_LINK_NEW" ]; then
NIX_LINK="$NIX_LINK_NEW" NIX_LINK="$NIX_LINK_NEW"
else else
if [ -t 2 ] && [ -e "$NIX_LINK_NEW" ]; then if [ -t 2 ] && [ -e "$NIX_LINK_NEW" ]; then