Per-user profiles not created when $HOME mounted on NFS

I did some more experimenting that cleared up some things for me.

The big-lock permission denied issue

The

$ nix-shell -p nix-info --run "nix-info -m"
error: opening lock file '/nix/var/nix/db/big-lock': Permission denied

issue with Nix 2.3 and 2.3.2 was due to me not deleting/stopping nix-deamon.service and nix-deamon.socket prior to installing Nix. I.e., i didn’t follow the first step in the “Uninstalling nix” instructions presented by the installer.

Fixed it by following instructions properly.

Issue with per-user directories not being created

After the above was fixed, the issue with per-user directories not being automatically created when running nix-env -i ... is still present in Nix 2.3.2. I.e., i get

$ nix-env -i nix-prefetch-git
installing 'nix-prefetch-git'
error: opening lock file '/nix/var/nix/profiles/per-user/.../profile.lock': No such file or directory

If i roll back to Nix 2.3, the issue is gone – the per-user directory gets created (same as described in my previous post) and nix-prefetch-git gets installed. So it still seems to be a bug with Nix 2.3.2.

The discrepancy between Nix 2.3 and 2.3.2 is the cause of different behaviors of the various hosts i described above. Nix 2.3.2 was installed on the newer hosts and that’s why the issues started.

The effect of $HOME being on NFS

Turns out that Nix 2.3.2 acts differently depending whether i’m running nix-env -i ... from a user whose $HOME is on an NFS drive (that’s the case for all of the debugging done above) or from a regular user whose home resides on a local drive. When using a local user, i’m able to run nix-env -i nix-prefetch-git without an issue on Nix 2.3.2 – it successfully creates /nix/var/nix/profiles/per-user/$USER for the local user. nix-env -i ... also works for users with home on NFS if i manually create the per-user directories as suggested by @NobbZ above.

EDIT:
I’ve posted an issue on GitHub Per-user profiles not created when $HOME mounted on NFS · Issue #3356 · NixOS/nix · GitHub