What does /nix/var/nix/gcroots/profiles point to?

Hello,

I’m reading the 11th nix pill about garbage collection. There, it says:

Turns out, that /nix/var/nix/gcroots/profiles is a symlink to /nix/var/nix/profiles

However, on my system I have:

[corentin@nixos-qemu-vm:~]$ ls -l /nix/var/nix/gcroots/profiles                                  
lrwxrwxrwx 1 root root 25 Dec  8 13:40 /nix/var/nix/gcroots/profiles -> /mnt/nix/var/nix/profiles

But what is /mnt/nix/var/nix/profiles? The whole /mnt directory is missing from my system:

[root@nixos-qemu-vm:/home/corentin]# ls /mnt
ls: cannot access '/mnt': No such file or directory

[root@nixos-qemu-vm:/home/corentin]# ls /mnt/nix/var/nix/profiles
ls: cannot access '/mnt/nix/var/nix/profiles': No such file or directory

Is there some magic around /mnt in NixOS? For what it’s worth:

[root@nixos-qemu-vm:/home/corentin]# nixos-version 
19.09.1529.808d3c6d123 (Loris)
2 Likes

I noticed this and wondered about it too. I wonder if it is from during the install, at which point /mnt made sense. I’ll try and see by doing a different install.

FWIW my NixOS install doesn’t have this, it points to /nix/var/nix/profiles.

I can reproduce it with a brand new NixOS install, and it was mounted at /newsys, so the symlink ends up being /nix/var/nix/gcroots/profiles -> /newsys/nix/var/nix/profiles. I did use my own NixOS installer ISO, but I don’t think that makes much of a difference.

1 Like

Also relevant, My /nix/var/nix/gcroots/profiles symlinks to /mnt/nixos/nix/var/nix/profiles instead of just /nix/var/nix/profiles · Issue #73812 · NixOS/nixpkgs · GitHub

1 Like

It looks like a bug. The mount path used during installation should not leak into the install destination.

I followed the official install guide which tells users to mount the new root
at /mnt so that would explain why it’s /mnt in my case. I used the NixOS
installer ISO.

I asked the same question here: Nix garbage collector is implemented differently from how it is documented · Issue #3060 · NixOS/nix · GitHub and it sounds to me like the linked change is related to how the bug got introduced.

2 Likes

I had noticed that my NixOS has a strange dangling pointer in GC roots and found this thread now. Thank you for explanation.

Bug present in NixOS 24.05. I just merged multiple duplicate bug reports into:

1 Like