My nix-darwin + home-manager setup, using Determinate Nix to manage the macOS environment.
- Use
determinate-nixto install and manage the Nix version. nix-macis a public repository based onnix-darwin+home-manager, managing essential macOS software likezsh,postgresql, etc.dot-secis a private repository based onhome-manager, managing private configuration data, includingsops-nix,age,ssh, and more.dot-secis a standalone git repo, symlinked to~/.secas an optionalhome-managersubmodule.- If
~/.secexists, it will be deployed together withdarwin-rebuild. - If it doesn't exist, it won't affect the
nix-darwindeployment—just a missing notice will be shown.
- If
- Install Determinate Nix.
- Clone the
nix-macrepository. - Run
darwin-rebuildto switch configurations. - Run
iupfor further initialization.
- Sign in to your Apple ID and ensure a stable internet connection.
- Installing
HomebrewandXcode Command Line Toolsmay require significant downloads.
Recommended: use the Determinate Nix Installer:
curl -fsSL https://install.determinate.systems/nix | sh -s -- install
## need auth login???For the pkg installer, see:
- https://docs.determinate.systems/getting-started/individuals/
- https://install.determinate.systems/determinate-pkg/stable/Universal
References:
- https://zenn.dev/trifolium/articles/da11a428c53f65?locale=en
- https://github.com/NixOS/nix-installer
- https://github.com/DeterminateSystems/nix-installer
Test the installation:
nix shell nixpkgs#hello
nix shell nixpkgs#hello --command hello --version
nix run nixpkgs#hello -- --version
nix shell github:NixOS/nixpkgs/nixos-unstable#hello
nix run nixpkgs#cowsay -- "Hello"
# nix shell nixpkgs#pkg1 nixpkgs#pkg2# First time
mkdir -p ~/dev && cd ~/dev
git clone -v --depth=3 https://github.com/cao7113/nix-mac.git
cd nix-mac
sudo nix run "nix-darwin/nix-darwin-26.05#darwin-rebuild" -- switch --flake ".#mac" --show-trace --impure
# Then
iupxcode-select --install
# Check the current path:
xcode-select -pIf your network is unstable, you can temporarily comment out the Homebrew section in flake.nix.
It is recommended to install jnoortheen.nix-ide:
nix profile add github:DeterminateSystems/fh
# Temporary shell install:
nix shell "https://flakehub.com/f/DeterminateSystems/fh/*"
nix run github:DeterminateSystems/fh -- --help
fh --versiongh auth login
gh ssh add ~/.ssh/id_ed25519.pubIf your network is unstable, you can use ShadowsocksNG:
export http_proxy=http://127.0.0.1:1087
export https_proxy=http://127.0.0.1:1087- https://github.com/nix-community/home-manager
- https://home-manager-options.extranix.com/?query=direnv&release=release-25.11
- https://github.com/nix-darwin/nix-darwin
- https://nix-darwin.github.io/nix-darwin/manual/index.html
- https://callistaenterprise.se/blogg/teknik/2025/05/28/nix-darwin/
- https://github.com/HestHub/nixos
- https://nix.dev/manual/nix/2.28/introduction.html