nixmac

Config as Code

Your nix-darwin configuration explained

nixmac manages a standard nix-darwin configuration. Your Mac's packages, settings, and system preferences are declared in .nix files that you can read, edit, version-control, and use independently of nixmac.

Your configuration directory

By default, your nix-darwin configuration lives at ~/.darwin/. This is a git repository containing your flake.nix and module files. You can change this location in the app's settings.

A typical structure:

~/.darwin/
├── flake.nix                    # Flake inputs and darwin configuration entry point
├── flake.lock                   # Pinned dependency versions
├── modules/
│   └── darwin/
│       ├── packages.nix         # System packages
│       ├── defaults.nix         # macOS system preferences
│       ├── homebrew.nix         # Homebrew casks and brews
│       ├── fonts.nix            # Fonts
│       ├── home.nix             # Home-manager user config
│       ├── environment.nix      # Environment variables
│       ├── networking.nix       # Network settings
│       ├── security.nix         # Security preferences
│       ├── services.nix         # System services
│       └── users.nix            # User accounts
└── nix-overlays.nix             # Package overlays

The flake

Your flake.nix uses standard nix-darwin and nixpkgs:

{
  description = "My Mac configuration";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
    nix-darwin.url = "github:nix-darwin/nix-darwin/master";
    nix-darwin.inputs.nixpkgs.follows = "nixpkgs";
  };

  outputs = inputs@{ self, nix-darwin, nixpkgs, ... }: {
    darwinConfigurations."my-mac" = nix-darwin.lib.darwinSystem {
      modules = [
        ./modules/darwin/packages.nix
        ./modules/darwin/defaults.nix
        # ... other modules
      ];
    };
  };
}

This is regular nix-darwin configuration, with nixmac's bundled bootstrap template adding Determinate Nix-friendly defaults and an AI-friendly module layout. nixmac doesn't define its own configuration language — it uses nix-darwin directly.

What you can configure

Packages

Add packages to environment.systemPackages in modules/darwin/packages.nix:

{ pkgs, ... }:
{
  environment.systemPackages = with pkgs; [
    git
    ripgrep
    fd
    bat
    neovim
    nodejs
  ];
}

This is standard nix-darwin syntax. Any package in nixpkgs (100,000+ packages) is available.

With nixmac, you can also just say "install ripgrep" and the AI agent will edit this file for you.

macOS system defaults

Configure macOS preferences in modules/darwin/defaults.nix:

{ ... }:
{
  system.defaults.dock = {
    autohide = true;
    show-recents = false;
    mru-spaces = false;
    orientation = "left";
    tilesize = 48;
  };

  system.defaults.NSGlobalDomain = {
    AppleShowAllExtensions = true;
    InitialKeyRepeat = 15;
    KeyRepeat = 2;
  };

  system.defaults.finder = {
    AppleShowAllExtensions = true;
    FXPreferredViewStyle = "clmv";
  };
}

These map to the same defaults write commands you'd run manually, but declared in code. See the nix-darwin options reference for all available system.defaults.* keys.

Homebrew integration

nixmac supports managing Homebrew casks and formulae through nix-darwin:

{ ... }:
{
  homebrew.enable = true;
  homebrew.casks = [
    "firefox"
    "slack"
    "1password"
  ];
  homebrew.brews = [
    "awscli"
  ];
}

Environment variables

{ ... }:
{
  environment.variables = {
    EDITOR = "nvim";
    LANG = "en_US.UTF-8";
  };
}

Version control

Your ~/.darwin/ directory is a git repository. nixmac commits changes automatically when you accept them. You can also manage it manually:

cd ~/.darwin
git log --oneline        # see change history
git diff                 # see uncommitted changes
git remote add origin <your-repo>
git push                 # back up to a remote

Clone on another Mac, point nixmac at it, and you have the same configuration.

Escape hatch

nixmac does not lock you in. You can always:

  • Edit any .nix file directly in your editor
  • Rebuild without nixmac using nix-darwin directly:
    # If darwin-rebuild is on your PATH:
    darwin-rebuild switch --flake ~/.darwin
    
    # On Determinate Nix installs (darwin-rebuild is not globally installed):
    sudo -i nix run nix-darwin/master#darwin-rebuild -- switch --flake ~/.darwin
  • Use the configuration with plain nix-darwin on a machine without nixmac installed

Next steps

On this page