Keystone SystemsKS Systems

Installing Nix on macOS

This guide covers installing Nix on macOS, including Apple Silicon and Intel Macs.

Prerequisites

  • macOS 10.15 (Catalina) or later
  • Admin access
  • Command Line Tools: xcode-select --install

Installation

Option 1: Determinate Nix Installer (Recommended)

The Determinate Systems installer handles macOS-specific requirements automatically:

curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install

Benefits:

  • Flakes enabled by default
  • Handles APFS volume creation
  • Clean uninstall option
  • Better error handling for macOS quirks

Option 2: Official Installer

sh <(curl -L https://nixos.org/nix/install)

This installs Nix in multi-user mode, which is required on macOS.

Post-Installation

Restart your terminal or source the Nix profile:

# For bash/zsh
. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh

Verify the installation:

nix --version
# nix (Nix) 2.x.x

nix run nixpkgs#hello
# Hello, world!

Enabling Flakes

If using the official installer, enable flakes:

mkdir -p ~/.config/nix
echo "experimental-features = nix-command flakes" >> ~/.config/nix/nix.conf

Restart the nix-daemon:

sudo launchctl stop org.nixos.nix-daemon
sudo launchctl start org.nixos.nix-daemon

macOS-Specific Notes

APFS Volume

Nix creates a dedicated APFS volume mounted at /nix. This is required because macOS's System Integrity Protection prevents creating directories at the root level. The installer handles this automatically.

You'll see the volume in Disk Utility as "Nix Store".

After macOS Upgrades

Major macOS updates occasionally break Nix. Common fixes:

# Remount the Nix volume
sudo launchctl kickstart -k system/org.nixos.darwin-store
sudo launchctl kickstart -k system/org.nixos.nix-daemon

# If that fails, check /etc/synthetic.conf contains:
nix

Rosetta 2 (Apple Silicon)

Some packages may require x86_64 emulation:

# Install Rosetta if needed
softwareupdate --install-rosetta --agree-to-license

# Run x86_64 packages
nix run nixpkgs#legacyPackages.x86_64-darwin.somePackage

Troubleshooting

"nix-daemon not running"

sudo launchctl load /Library/LaunchDaemons/org.nixos.nix-daemon.plist
sudo launchctl start org.nixos.nix-daemon

Permission Denied Errors

Ensure your user is in the nixbld group (the installer should handle this):

groups $USER | grep nixbld

Reinstalling

With Determinate installer:

/nix/nix-installer uninstall

Then run the installer again.

Next Steps