Renaming a user breaks nix-env on new install with old home-directory
After renaming a user, /home/[newname]/.nix-profile still points to /nix/var/nix/profiles/per-user/[oldname]/profile. This works fine, until for some reason /nix is regenerated - for example due to reinstalling NixOS but keeping the old home directory.
Then, nix-env fails with error: opening lock file '/nix/var/nix/profiles/per-user/[oldname]/profile.lock': No such file or directory. This could be either a documentation, an error message or an implementation issue, depending on how you see it.
This is related to https://github.com/NixOS/nix/issues/509. We should move per-user data out of /nix/var/nix and into their home directories.
I marked this as stale due to inactivity. → More info
I closed this issue due to inactivity. → More info
Today single-user install failed me with the error below:
copying Nix to /nix/store....................................................
installing 'nix-2.22.1'
building '/nix/store/x8hfibkpb6as4rji91ln5xp5lnj02gn8-user-environment.drv'...
error: opening lock file '/nix/var/nix/profiles/per-user/<user>/profile.lock': No such file or directory
/tmp/nix-binary-tarball-unpack.kaPc1MktsZ/unpack/nix-2.22.1-x86_64-linux/install: unable to install Nix into your default profile
And i could make it work deleting ~/.nix-profile after reading this issue