I am on Macbook Pro M1 Monterey and I restarted by machine. Nix executables could not be found. So I did a search for them and found a whole bunch of them below.
So I want to know the default location for a fresh install of nix. Reinstalling is complicated so I would rather just try to reset the path variable. I would also suggest “Nix Store” with a space is a bit unusual place to find a bin directory.
I am assuming that the one I want is the 2.8.0 but I don’t recall seeing this in $PATH before.
The default location is indeed in the store, though there is a generated script that knows how to find nix properly.
Make sure to source it from your users shell rc, rather than from the system.
Check the installation manual for where to find the script, as it lives in different locations depending on whether you did a multi or single user installation.
If you rebooted because you updated macOS, the problem is probably, as nobbz mentions, Apple’s update overwriting /etc/zshrc. AFAIK they generally don’t clobber /etc/bashrc, so you can find a copy of the shell hook at the end of that file and re-add it to /etc/zshrc.
If you didn’t update macOS (which you comment about still seeing the hook in zshrc suggests), the problem is presumably that something else in your shell profile is overriding. This generally takes the form of something that runs before the shell hook aborting early, or something afterwards (often in your user profile) hard-setting the PATH instead of merely prepending/appending.
Actually… I’m probably getting ahead of us. The paths you’re citing (/System/Volumes/Data/Volumes/Nix Store) may mean something more fundamental isn’t working.
The store is on its own volume which should be mounted at /nix, so make sure you see /nix/store (i.e., run ls /nix/store). If not, the problem is probably whatever is keeping your store volume from mounting. Your shell hook may be fine.
Well I had two users on my Macbook one seems to have been created by Nix called Other then I added another admin user. When I rebooted it asked for admin permission because of multiple users being affected which I provided, and after that it seemed to have overwritten /etc/zshrc
I’m not sure how it got removed, but this is probably your problem.
The file should contain nix on a line by itself. You can do this with an editor if you like, but you can also run the equivalent of what the installer does:
Ok, it probably had to do my having tried run a second install of nix from the other admin user. I was trying to do a fresh install and dev environment under a new user and perhaps that affected it.
/nix is now there but I don’t see anything under it
/nix % ls -la
total 0
drwxr-xr-x 2 root wheel 64 Apr 28 02:03 .
drwxr-xr-x 20 root wheel 640 Feb 26 14:05 .
What I recall is that fstab had /nix appearing just before or after apfs I think like below:
UUID=9D26308A-5246-4280-9DB2-10913B6FAA82 /nix apfs rw,noauto,nobrowse,suid,owners
I did modify this once during an uninstall but after that it reinstalled successfully and I had been using nix commands ok
The uninstall recommendation was to remove nix from fstab and I removed just the directory perhaps it was the entire line that should have been removed during the uninstall.
Egh. So, what you’re seeing now is the empty mountpoint for the volume (created by macOS based on synthetic.conf). Since your volume isn’t mounted, there’s some kind of inconsistent state between fstab, the actual volume(s) on your system, and the mounting service script (stored in /Library/LaunchDaemons/org.nixos.darwin-store.plist).
You’re right that /nix should be present in the fstab between the UUID and apfs (and, yes–the instructions meant to remove the entire line).
We can keep trying to debug, but TBH it will probably be faster to follow the uninstall instructions at Installing a Binary Distribution again (with the complete removal of the line from fstab, and with an edit to the 7th step–just manually open Disk Utility and delete any/all volumes named Nix Store), and try a fresh install.
Ok, just wondering how does this affect the nix stores used in my existing project where I ran nix-shell? I think it downloaded lots of items over a few hours. Would those be lost on a reinstall? Not a huge loss, I am just curious if these stores are separate or not?
In terms of determining which store is the correct one is there anyway to go from the item in the store to find this? For example I see this during the original compilation