Broken $HOME/.nix-profile symlink on a fresh installation

Hi,

As the title says, on a fresh installation, the $HOME/.nix-profile soft symbolic link is broken:

I spent some time configuring my configuration.nix, and so far, everything seems to be working correctly, which means that as a newbie to NixOS, I’m missing something here.

I briefly searched here but couldn’t find any related issues.

After asking a couple of different LLM oracles (?), they both suggested:

ln -sf /nix/var/nix/profiles/default ~/.nix-profile

However, these tools are good if you know something about the topic. Otherwise, it gets hairy quickly, and I just started to scratch NixOS’s surface.

When taking a look at /nix/var/nix/profiles/, this is what I’ve got there:

I’d greatly appreciate it if anyone could point me to the right manual section or any other documentation where I can learn exactly how this symlinking works and how to fix it properly.

Thanks!

The oracles are likely correct. I can’t point you to the specific part of the documentation that talks about this, but this is what it looks like on my machine (macOS):

lrwxr-xr-x     - lucian 20 Jun  2023 .nix-profile -> /nix/var/nix/profiles/per-user/lucian/profile

I also remember having this issue on a fresh install, but I never investigated what was going on.

1 Like

Hello!

What you’re seeing is normal and nothing to worry about.

The directory ~/.local/state/nix/profiles is where your user profiles live. If you haven’t installed anything per user yet (by doing something like niv-env -iA or nix profile install) then this directory is empty. Once you install something using the commands above, a symlink profile-1-link to the corresponding profile in the Nix Store will be created in this directory as well as a symlink profile that points to profile-1-link to make it easily available in your $PATH.

For further info see one of my old posts here on DIscourse and the respective section in the Nix Reference Manual. I also recommend watching part of the video “Everyday Use of GNU Guix” (minutes 23 to 37) by Chris Marusich on YouTube, who explains how the linking system works. (Nix is similar to Guix in this regard, but the given commands differ.)

2 Likes