Nix-darwin setup for an M3 mac, a variant of nix for macs.
- Install Nix, multi-user installation.
- Install Homebrew. Not strictly nescessary, but some apps are not in nixpkgs, and nix integrates nicely with homebrew.
- Borrow nescessary parts off of the nix-darwin-kickstarter/minimal, and put it in
~/.config/nix-darwin
(this repo). - Install nix-darwin, using nix it self, and nix flakes
nix --extra-experimental-features 'nix-command flakes' \
run nix-darwin -- switch --flake ~/.config/nix-darwin
darwin-rebuild switch --flake ~/.config/nix-darwin
(needs root)
- flake.nix
- main entrypoint
- systems configuration: only one for a single mac
- dependency setup: inputs
- flake.lock
- pinned versions of all dependencies
- modules/
- apps.nix: system and homebrew packages
- host-users.nix: machine and user setup
- nix-core.nix: configuration of nix itself on the machine
- system.nix: mac specific settings; dock, keyboard, finder++
- home/
- home manager modules: user specific package configuration
- most of these modules are pulled in from torgeir/nix-home-manager
pkgs, overlays, overrides++
- patch-nerd-fonts: a derivation to patch a font with nerd font symbols
- firefox-extensions.nix: borrow rycee’s code from NUR (Nix User Repository) for installing firefox extensions
- emacs with a few patches: overridden emacs29 package to compile it with selected patches, inspired by noctuid’s config, e.g. to work with the yabai tiling vm
aka dependencies
- nixpkgs-darwin: nixpkgs for macos
- nix-darwin: nix support for configuring macs
- home-manager: nix module for user specific package configuration
aka nix package extensions or modifications
- nixpkgs-firefox-darwin: an overlay to provide firefox built for darwin
you can bump all inputs/dependencies, which updates the flake.lock
, with
nix flake update
you can bump a single input, e.g. nixpkgs-firefox-darwin, with
nix flake lock --update-input nixpkgs-firefox-darwin
remember to darwin-rebuild switch
afterwards
when you recreate your system for the millionth time, you might end up with multiple applications that no longer represent what your config means should be the current one, meaning commands like open -a <app name>
and “Open With” might open apps you no longer mean to have installed
you can see all these generations of systems with
darwin-rebuild --list-generations
you can find out what is keeping built derivations alive by looking up their path in the nix store
nix-store --query --roots /nix/store/...
you can clean up leftover generations older than 7 days with
nix-collect-garbage --delete-older-than 7d
sudo nix-collect-garbage --delete-older-than 7d
you can clean up all leftover generations with
nix-collect-garbage -d
sudo nix-collect-garbage -d