GuidesDeploy Nix on macOS EC2

Deploy Nix on macOS EC2

This guide explains how to deploy Determinate Nix on Amazon EC2 macOS instances with fully automated installation and FlakeHub integration covering secure IAM authentication, instance store configuration, and auto-scaling deployment patterns for enterprise CI/CD workloads.

Prerequisites

Security considerations

Instance store persistence

When deploying Nix on EC2 macOS instances, the Nix store is installed to the instance’s ephemeral instance store. This means:

  • The Nix store is erased when the instance is stopped
  • EBS snapshots do not capture the Nix store
  • Standard macOS reboots are safe

IAM authentication

Use AWS IAM roles to control access to FlakeHub Cache:

  1. Create an IAM role with appropriate permissions
  2. Attach the role to your EC2 instance
  3. Register the role ARN in your FlakeHub organization settings
  4. Install/restart Determinate to authenticate with FlakeHub using the role

Supported use cases

Use CaseStatusNotes
Ephemeral instances✅ SupportedIdeal for CI/CD and batch processing
Auto-scaled fleet✅ SupportedWorks with ASG and launch templates
Long-running instances❌ Not supportedInstance store is wiped on stop/start
Snapshotted instances❌ Not supportedStore not captured in EBS snapshots

Installation

Launch

Launch your macOS EC2 instance with an appropriate IAM role.

Install

Install Determinate Nix with EC2 instance store support:

curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | \
  sh -s -- install macos \
  --no-confirm \
  --determinate \
  --use-ec2-instance-store

Verify

Verify the installation:

# Check Nix works
nix --version
 
# Verify FlakeHub authentication
determinate-nixd status

Using with AWS Auto Scaling

Create template

Create a launch template that includes the installation script in user data:

#!/bin/bash
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | \
  sh -s -- install macos \
  --no-confirm \
  --determinate \
  --use-ec2-instance-store

Configure

Configure your Auto Scaling Group to use the launch template.

Sit back and relax

New instances automatically install Nix and authenticate with FlakeHub using their IAM role.

Next steps

Troubleshooting

If you encounter issues: