macOS flake layout using:
nix-darwinfor macOS system settingsnix-homebrew+homebrewmodule for Homebrew packages and caskshome-managerfor user-level dotfiles and shell config
.
|-- flake.nix
|-- scripts/ # Custom scripts installed into PATH
| `-- rebuild # Build and switch system configuration
|-- config/ # Dotfile configs (symlinked)
| |-- ghostty/
| |-- karabiner/
| |-- nvim/
| |-- rime/
| |-- starship.toml
| |-- tmux/
| `-- zsh/
|-- hosts/
| |-- darwin-arm64-main/
| | `-- default.nix
| `-- darwin-x86_64-legacy/
| `-- default.nix
|-- home/
| `-- <username>/
| `-- default.nix
`-- modules/
|-- darwin/
| |-- default.nix
| |-- packages.nix
| `-- settings.nix
|-- home-manager/
| |-- default.nix
| |-- git.nix
| |-- packages.nix
| |-- zsh.nix
`-- homebrew/
`-- default.nix
| Category | Tools |
|---|---|
| Core | bat eza fd fzf git neovim ripgrep tmux tree wget zoxide |
| Languages | go rust rust-analyzer python3 nodejs |
| Dev Tools | gh gitmux sesh starship uv yq |
| Shell | oh-my-zsh zsh-autosuggestions zsh-syntax-highlighting |
| Category | Apps |
|---|---|
| Communication | WeChat DingTalk Telegram QQ |
| Input | Squirrel (Rime) |
| Browser | Arc Chrome |
| IDE | Zed VSCode Neovim |
| AI | CC-Switch |
| Note | Obsidian Logseq |
| Terminal | Ghostty iTerm2 |
| Player | IINA |
| Productivity | Raycast Karabiner Easydict OrbStack MonitorControl |
| Other | Snipaste f.lux Beekeeper Studio Mos MQTTX |
| Fonts | Fira Code Monaspace |
| Proxy | clash-party |
mole- Deep clean and optimize Mac
| Config | Location |
|---|---|
| Ghostty | ~/.config/ghostty |
| Karabiner | ~/.config/karabiner |
| Neovim | ~/.config/nvim |
| Rime | ~/Library/Rime (rime-ice + custom) |
| Starship | ~/.config/starship.toml |
| Tmux | ~/.config/tmux |
| Zsh | ~/.zshrc |
- Shared config lives in
modules/ - Shared user config lives in
home/<username>/ - Dotfile configs live in
config/(symlinked) - Per-machine differences live in
hosts/<hostname>/
Most of your CLI tools, shell config, dotfiles, and env vars should stay shared. Host files should stay thin and only describe machine-specific differences.
darwin-arm64-main: Apple Silicon,aarch64-darwindarwin-x86_64-legacy: Intel,x86_64-darwin
These names are logical host roles, not hardware model names.
- System CLI tools:
modules/darwin/packages.nix - GUI apps from Homebrew:
modules/homebrew/default.nix - User shell config:
modules/home-manager/zsh.nix - Dotfile configs:
config/(symlinked viahome/<username>/default.nix) - Custom scripts:
scripts/(installed into PATH viamodules/home-manager/packages.nix)
Per-project dev environments are managed via kalifun/devshells + direnv.
mkdevshell is installed globally as a system package. Use it to generate a .envrc:
mkdevshell simple rust-stableModes:
- simple
<name>— writesuse flake github:kalifun/devshells#<shell>to.envrc, activates immediately - composite — interactive fzf multi-select to combine shells
- template [name] — initialize a project with
nix flake init
Available shells: go-latest, go-1_25, go-1_24, nodejs-22, nodejs-20, python-313, python-311, python-314, rust-stable, rust-nightly, rust-nightly-wasm, lua, zig, zig-latest, thrift, nix, java-android
Choose one bootstrap mode before the first apply.
Set nix.enable = true in modules/darwin/settings.nix.
In this mode, nix-darwin is allowed to manage the Nix installation.
Install Nix with the official installer, then open a new shell:
curl -L https://nixos.org/nix/install | shFirst apply:
Apple Silicon:
nix run github:LnL7/nix-darwin/master#darwin-rebuild -- switch --flake .#darwin-arm64-mainIntel:
nix run github:LnL7/nix-darwin/master#darwin-rebuild -- switch --flake .#darwin-x86_64-legacyLater applies:
Apple Silicon:
sudo darwin-rebuild switch --flake .#darwin-arm64-mainIntel:
sudo darwin-rebuild switch --flake .#darwin-x86_64-legacyKeep nix.enable = false in modules/darwin/settings.nix.
In this mode, Nix is managed outside nix-darwin.
Install Determinate Nix, then open a new shell.
First apply:
Apple Silicon:
nix run github:LnL7/nix-darwin/master#darwin-rebuild -- switch --flake .#darwin-arm64-mainIntel:
nix run github:LnL7/nix-darwin/master#darwin-rebuild -- switch --flake .#darwin-x86_64-legacyLater applies:
Apple Silicon:
sudo darwin-rebuild switch --flake .#darwin-arm64-mainIntel:
sudo darwin-rebuild switch --flake .#darwin-x86_64-legacyIn both modes, the first apply uses nix run because darwin-rebuild is usually not available until after the first successful switch.
You can also use the rebuild script from the dotfiles directory:
rebuild # switch to current config
rebuild --update # update all flake inputs, then switchOn recent macOS versions, System Settings > General > Login Items & Extensions > Allow in the Background
may show some Nix-related background items as plain sh entries.
These are easy to mistake for something suspicious, but they are required for nix-darwin /
Determinate Nix boot integration. On this setup they may include:
org.nixos.activate-systemorg.nixos.darwin-storesystems.determinate.nix-installer.nix-hook
If you disable those sh entries, the system profile may not be restored on the next boot.
Typical symptoms:
/run/current-systemis missing after reboot- commands from
environment.systemPackagesare no longer found - shell startup reports errors such as
command not found: starshiporcommand not found: zoxide
If that happens, re-enable the related sh entries in Allow in the Background and reboot.
If you need an immediate recovery without rebooting, run:
sudo launchctl bootstrap system /Library/LaunchDaemons/org.nixos.activate-system.plist
sudo launchctl kickstart -k system/org.nixos.activate-system