A basic configuration comprising essential settings for initiating nix-darwin. It can be safely deployed to your system.
- Install Nix package manager via Nix Official or DeterminateSystems/nix-installer.
- Read all the files in this
minimal
folder, and understand what they do.- If you have trouble understanding, ryan4yin/nixos-and-flakes-book is a good resource to learn nix and flakes.
- Install Homebrew, see https://brew.sh/
- Homebrew is required to install most of the GUI apps, App Store's apps, and some CLI apps that are not available in nix's package repository
nixpkgs
.
- Homebrew is required to install most of the GUI apps, App Store's apps, and some CLI apps that are not available in nix's package repository
- Search
TODO
in thisminimal
folder, and complete all the TODOs. - Run the following command in the root of your nix configuration to start your nix-darwin journey(please change
hostname
to your hostname):nix build .#darwinConfigurations.hostname.system \ --extra-experimental-features 'nix-command flakes' ./result/sw/bin/darwin-rebuild switch --flake .#hostname
To simplify the command, adding the following content by create a Makefile
in the root of your nix configuration:
# please change 'hostname' to your hostname
deploy:
nix build .#darwinConfigurations.hostname.system \
--extra-experimental-features 'nix-command flakes'
./result/sw/bin/darwin-rebuild switch --flake .#hostname
Then you can run make deploy
in the root of your nix configuration to deploy your configuration.
Your current nix-darwin configuration's structure should be as follows:
› tree
.
├── flake.lock # a lock file generated by nix, you can ignore it for now
├── flake.nix # the entry point of your nix configuration, you need to add your hostname here
├── modules # a folder contains all your nix-darwin configuration files
│ ├── apps.nix # contains all your homebrew & nix apps(both GUI & CLI)
│ ├── host-users.nix # defines your hostname & all your system users
│ ├── nix-core.nix # nix's core configuration, you can ignore it for now
│ └── system.nix # defines your macOS's system configuration(like dock, trackpad, keyboard, finder, loginwindow, etc.)
└── README.md
If you are in a network environment that requires proxy(such as China), you may need to set up proxy for nix and homebrew.
Please refer to the rich-demo
folder for more details: