Heya! I’m using Nix on top of a Debian installation. Yesterday, I tried moving my /nix folder onto a separate btrfs subvolume so that I wouldn’t be having my nix store captured in my btrfs snapshots. I just used the mv command to do this, but it appears doing that has caused nix-daemon to break. Now, whenever I run just about any nix-related command without sudo, I get an error like this:
cannot connect to socket at '/nix/var/nix/daemon-socket': Connection refused
What’s the best way to fix this? Am I best off just re-installing Nix, or is that not needed? Also how would I move my /nix next time I have to do something like this, so I don’t break everything?
It appears a sudo systemctl restart nix-daemon makes the affected Nix commands work again, but only until I reboot the system, and then it returns to being broken.
How do I configure nix-daemon to make it look at the new /nix at startup?
Maybe the problem is that /nix is getting mounted after nix-daemon starts? Maybe I can set up a systemd mountpoint for /nix with the service for nix-daemon requiring that mountpoint? I’ll try that out and see if it works.
Ok, I fixed the problem. Turns out that if you have /nix on a separate partition or subvolume, systemd will not be made aware of the nix-daemon service immediately, since it lives in the nix store and is symlinked to /etc/systemd/system. You have to run systemctl daemon-reload at startup to make it aware of the nix-daemon service so it can actually be loaded.
I made a mount unit for /nix (nix.mount) and a service unit to run the daemon-reload command (ensure-symlinked-units-resolve.service).
I have also mv /nix /media/partition2 to a other (bigger) partition. Created a symlink with ln -s /media/partition2/nix /nix Now nix seems to works but not fully: