NIX_PROFILE should not be set or should be pointed to the NIX_STATE_DIR.
The nix-daemon.conf
environment.d config file is configuring the NIX_PROFILE
env variable to $HOME/.nix-profile
, but nix itself assumes that if you pass that environment variable it would be an absolute path to the location where the state for the links for the generation will be managed (like passing --profile
). If NIX_PROFILE
is set to $HOME/.nix-profile
it will start to create the generation links (in the form of profile-<GEN_NUMBER>-link)
in the home directory instead of in /nix/var/nix/profiles/per-user/$USER/profile
.
If the variable is not set, then it proceeds with the default behavior of following the symlink and create the link generations in the /nix/var/nix/profiles/per-user/$USER/profile
.
Link to the relevant code segment for 2.3.4
Can be easily tested by unset NIX_PROFILE
and compare the nix-env
behavior.
Alternatively instead of removing the variable, could be set to /nix/var/nix/profiles/per-user/$USER/profile
and make sure the symlink in the home exists (this symlink is always static to the latest link in /nix/var/nix/profiles/per-user/$USER/profile
).