2

I can't find nix-env, nix-build, nix-shell etc. on MacOS Catalina.

I installed with:

sh <(curl https://nixos.org/nix/install) --darwin-use-unencrypted-nix-store-volume

and was able to run them yesterday. I restarted my computer and can no longer find them. find / -name nix-env | grep nix-env shows nothing.

I tried installing again with the same command (sh <(curl https://nixos.org/nix/install) --darwin-use-unencrypted-nix-store-volume) but this time it exists immediately with 0 status code.

I suspect I need to do something to mount a virtual drive.

leopold
  • 1,971
  • 1
  • 19
  • 22
Max Heiber
  • 14,346
  • 12
  • 59
  • 97
  • Did you check https://nixos.org/manual/nix/stable/#sect-macos-installation? Which instructions did you follow? – Robert Hensing Oct 29 '20 at 21:53
  • Thanks @RobertHensing, I followed those instructions, which say to do `sh <(curl -L https://nixos.org/nix/install) --darwin-use-unencrypted-nix-store-volume` (as I wrote in the question) – Max Heiber Oct 31 '20 at 12:12
  • For later travelers, many of the details here changed with the Nov 1, 2021 release of Nix 2.4. – abathur May 05 '22 at 00:23

3 Answers3

1

You should follow Notes on the recommended approach.

It looks like the volume is not mounted (check /etc/fstab state with vifs as described in documentation).

Maxime
  • 452
  • 4
  • 9
  • doesn't work: `vifs: editing error`. If `cat /etc/fstab`, I see `LABEL=Nix\040Store /nix apfs rw,nobrowse` - exactly what the docs say should be there. But `nix-env` is still not available. – Max Heiber Nov 14 '20 at 11:54
  • Then your `/etc/fstab` looks good. Did you follow all the steps from this section? `apfs.util` and `diskutil` commands too? And which shell are you using? – Maxime Nov 16 '20 at 10:05
0

Use the Disk Utility UI to remove the nix volume (sudo rm -rf /nix won't work).

Then run the script again and cross fingers your fingers this time: sh <(curl https://nixos.org/nix/install) --darwin-use-unencrypted-nix-store-volume

Max Heiber
  • 14,346
  • 12
  • 59
  • 97
  • 1
    update: I restarted my computer again and `nix-env` is again gone. It seems like the solution is to reinstall every time I restart. – Max Heiber Nov 14 '20 at 11:55
0

While Nix (amongst others) installs with bash newer MacOS do use zsh instead of bash.

So you need to update your .zshrc to source this command from bash, too.

In your terminal start editing with:

sudo nano ~/.zshrc

and add:

source ~/.nix-profile/etc/profile.d/nix.sh

Reload and test with

source ~/.zshrc; nix --version
leopold
  • 1,971
  • 1
  • 19
  • 22
  • 2
    Sourcing bashrc from zshrc sounds like it could have unintended consequences: Bash and ZShell are different languages, after all. Zsh is not a strict superset of Bash, for example the same glob expansion syntax means something different in the two languages. – Max Heiber Jan 19 '22 at 17:13
  • 1
    It's a very bad idea. There's really only one line you need to add to `.zshrc` anyway, something like `. ~/.nix-profile/etc/profile.d/nix.sh`. Any other problems would be related to making sure the Nix store file system is properly mounted, which isn't something you will be doing from your shell configuration. – chepner Jan 19 '22 at 18:17
  • Acknowledged and updated. Thx guys – leopold Jan 25 '22 at 15:54
  • 1
    I can't find ~/.nix-profile/etc/profile.d/nix.sh – Kyrielight Nov 03 '22 at 12:52