macOS

This is my nix-darwin configuration for macOS (Apple Silicon).

Purpose

This configuration manages my work MacBook, providing a declarative way to configure macOS system settings and install applications via Homebrew.

System Defaults

macOS-specific settings for a better developer experience:

{ ... }:
{
  system.defaults = {
    # Dock
    dock = {
      autohide = true;
      show-recents = false;
      tilesize = 48;
    };

    # Finder
    finder = {
      AppleShowAllExtensions = true;
      ShowPathbar = true;
      FXEnableExtensionChangeWarning = false;
    };

    # Global settings
    NSGlobalDomain = {
      AppleShowAllExtensions = true;
      InitialKeyRepeat = 15;
      KeyRepeat = 2;
      NSAutomaticCapitalizationEnabled = false;
      NSAutomaticSpellingCorrectionEnabled = false;
    };

    # Trackpad
    trackpad = {
      Clicking = true;
      TrackpadRightClick = true;
    };
  };
  
  security.pam.services.sudo_local.touchIdAuth = true;
  system.primaryUser = "Gabriel.Morin";
  networking.hostName = "LNEX2HJR4J9K5";
  system.stateVersion = 6;
}

Homebrew

Since many macOS applications aren’t available in nixpkgs, Homebrew is used for GUI apps:

{ lib, ... }:
let
  customConfigPath = ./_homebrew-tm.nix;
  hasCustomConfig = builtins.pathExists customConfigPath;
  customConfig = if hasCustomConfig then (import customConfigPath { inherit lib; }) else { homebrew = {}; };
in
{
  homebrew = {
    enable = true;
    onActivation = {
      autoUpdate = true;
      cleanup = "zap";
      upgrade = true;
    };

    taps = [
      "homebrew/bundle"
      "homebrew/services"
      "openfga/tap"
      "databricks/tap"
      "LizardByte/homebrew"
      "peonping/tap"
    ] ++ (customConfig.homebrew.taps or []);

    brews = [
      "lz4"
      "xz"
      "awscli"
      "databricks/tap/databricks"
      "pulumi"
      "openfga/tap/fga"
      "kafka"
      "ttyd"
      "LizardByte/homebrew/sunshine"
      "PeonPing/tap/peon-ping"
    ] ++ (customConfig.homebrew.brews or []);

    # GUI Applications (casks)
    casks = [
      # Terminals
      "ghostty"
      "iterm2"
      "wezterm"

      # Editors & IDEs
      "visual-studio-code"
      "jetbrains-toolbox"

      # Browsers & Communication
      "discord"
      "spotify"

      # Development Tools
      "docker-desktop"
      "dbeaver-community"
      "claude-code"
      "burp-suite"
      "meld"
      "hoppscotch"

      # System Utilities
      "amethyst"
      "scroll-reverser"
      "stats"

      # Media
      #"gimp"
      "blackhole-2ch"

      # Kubernetes
      "freelens"

      # Fonts
      "font-hack-nerd-font"
      "font-jetbrains-mono-nerd-font"
    ] ++ (customConfig.homebrew.casks or []);
  };
}

Differences from NixOS

Unlike the NixOS hosts, macOS uses:

  • nix-darwin instead of NixOS modules
  • Homebrew for GUI applications (casks)
  • Different system defaults API
Links to this page