The nixos.org website suggests to use:
sh <(curl -L https://nixos.org/nix/install)
For macOS on Intel (x86_64) or Apple Silicon (arm64) based macs, we need to use
sh <(curl -L https://nixos.org/nix/install) --darwin-use-unencrypted-nix-store-volume
That's it!
Now we can use nix
as usual:
nix build -L '(import <nixpkgs> {}).hello.overrideAttrs (_: { HELLO = "WORLD"; })'
or
nix-shell -p haskell.compiler.ghc882
should just work.
I got it working eventually by running
sudo diskutil apfs addVolume disk1 APFS 'Nix Store' -mountpoint /nix
. But this really wasn't a nice installation experience. It would be great if Nix could take care of these low level operations behind the scenes because I have no idea what was happening when I ran this command.