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


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)
1 Like

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, https://github.com/NixOS/nixpkgs/issues/73812

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: https://github.com/NixOS/nix/issues/3060 and it sounds to me like the linked change is related to how the bug got introduced.


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