Keystone SystemsKS Systems

Installing NixOS on Mac Hardware

This guide covers installing NixOS on Intel-based Mac hardware, including MacBook Pro, MacBook Air, iMac, and Mac Mini.

Supported Hardware

Intel Macs: Most models work well with some hardware-specific configuration.

Apple Silicon: Experimental support via Asahi Linux. Not covered in this guide—see the Asahi NixOS project for current status.

This guide focuses on Intel Macs from approximately 2012-2020.

Prerequisites

  • USB drive (8GB minimum)
  • Backup all important data
  • External keyboard/mouse (useful if built-in input fails initially)
  • Wired ethernet adapter (recommended for initial setup)

Preparation

Disable Secure Boot (T2 Macs)

For Macs with T2 chip (2018+):

  1. Boot to Recovery Mode (hold Command+R during startup)
  2. Open Startup Security Utility from the Utilities menu
  3. Set Secure Boot to "No Security"
  4. Allow booting from external media

Resize macOS Partition (Dual Boot)

If keeping macOS:

  1. Boot into macOS
  2. Open Disk Utility
  3. Select the APFS container
  4. Click Partition and resize

Leave at least 50GB for NixOS, more for comfortable usage.

Creating Installation Media

Download the NixOS ISO from nixos.org (minimal or graphical installer).

From macOS/Linux

# Find your USB device
diskutil list  # macOS
lsblk          # Linux

# Write the image (replace /dev/diskX)
sudo dd if=nixos.iso of=/dev/rdiskX bs=4m status=progress

Verify

# Sync and eject
sync
diskutil eject /dev/diskX  # macOS

Boot and Install

Boot from USB

  1. Shut down the Mac
  2. Insert USB drive
  3. Power on while holding Option (Alt) key
  4. Select the USB drive (usually "EFI Boot")

Connect to Network

Wired ethernet works immediately. For WiFi, use wpa_supplicant or nmcli in the installer.

Partition the Disk

For a simple setup:

# Identify your disk
lsblk

# Use gdisk or parted
sudo gdisk /dev/nvme0n1

# Create:
# - 512MB EFI partition (type EF00)
# - Remaining space for root (type 8300, or 8304 for ZFS)

Install NixOS

Follow the standard NixOS installation, but generate hardware configuration:

sudo nixos-generate-config --root /mnt

Edit /mnt/etc/nixos/configuration.nix with Mac-specific options (see below).

Mac-Specific Configuration

Kernel and Firmware

{ config, pkgs, ... }: {
  # Enable firmware for WiFi, etc.
  hardware.enableRedistributableFirmware = true;

  # Some Macs need specific kernel modules
  boot.kernelModules = [ "applesmc" "hid_apple" ];

  # For HiDPI displays
  hardware.video.hidpi.enable = true;
}

Keyboard Configuration

{
  # Swap Option and Command to feel like macOS
  services.xserver.xkbOptions = "altwin:swap_alt_win";

  # Apple keyboard module options
  boot.extraModprobeConfig = ''
    options hid_apple fnmode=2
    options hid_apple swap_opt_cmd=1
  '';
}

Fan Control

{
  # Enable fan control for MacBook Pro
  services.mbpfan = {
    enable = true;
    settings.general = {
      min_fan1_speed = 2000;
      max_fan1_speed = 6000;
      low_temp = 55;
      high_temp = 58;
      max_temp = 86;
    };
  };
}

WiFi (Broadcom)

Many Macs use Broadcom WiFi chips:

{
  # For Broadcom BCM43xx
  boot.kernelModules = [ "wl" ];
  boot.extraModulePackages = [ config.boot.kernelPackages.broadcom_sta ];

  # Alternatively, some chips work with open-source driver
  # networking.enableB43Firmware = true;
}

FaceTime Camera

{
  # FaceTime HD camera (may require manual firmware extraction)
  hardware.facetimehd.enable = true;
}

Bluetooth

{
  hardware.bluetooth.enable = true;
  services.blueman.enable = true;
}

Trackpad

{
  services.libinput = {
    enable = true;
    touchpad = {
      naturalScrolling = true;
      tapping = true;
      clickMethod = "clickfinger";
    };
  };
}

Display Brightness

{
  # Backlight control
  programs.light.enable = true;
  # Or
  hardware.brightnessctl.enable = true;
}

Example Configuration

{ config, pkgs, ... }: {
  imports = [ ./hardware-configuration.nix ];

  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;

  hardware.enableRedistributableFirmware = true;

  boot.kernelModules = [ "applesmc" "wl" ];
  boot.extraModulePackages = [ config.boot.kernelPackages.broadcom_sta ];

  services.mbpfan.enable = true;

  networking.networkmanager.enable = true;

  services.libinput.enable = true;

  # ... rest of your configuration
}

Troubleshooting

No WiFi

Check which Broadcom chip you have:

lspci | grep -i wireless

Some chips need broadcom_sta, others need b43 with firmware.

Blank Screen After Boot

Try adding kernel parameters:

boot.kernelParams = [ "i915.modeset=1" "nomodeset" ];

Function Keys Not Working

Adjust fnmode:

boot.extraModprobeConfig = ''
  options hid_apple fnmode=0  # 0=fn key, 1=media keys, 2=fn key by default
'';

Next Steps