Skip to content

Instantly share code, notes, and snippets.

@frarredondo
Created March 12, 2025 19:24
Show Gist options
  • Save frarredondo/192930a454c992f306143bfc4eefc948 to your computer and use it in GitHub Desktop.
Save frarredondo/192930a454c992f306143bfc4eefc948 to your computer and use it in GitHub Desktop.
Example Flake Configuration for Apple Silicon
{
description = "Example nix-darwin system flake";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
nix-darwin.url = "github:LnL7/nix-darwin/master";
nix-darwin.inputs.nixpkgs.follows = "nixpkgs";
mac-app-util.url = "github:hraban/mac-app-util";
nix-homebrew.url = "github:zhaofengli-wip/nix-homebrew";
# Optional: Declarative tap management
homebrew-core = {
url = "github:homebrew/homebrew-core";
flake = false;
};
homebrew-cask = {
url = "github:homebrew/homebrew-cask";
flake = false;
};
homebrew-bundle = {
url = "github:homebrew/homebrew-bundle";
flake = false;
};
homebrew-services = {
url = "github:homebrew/homebrew-services";
flake = false;
};
};
outputs = inputs@{ self, nix-darwin, nixpkgs, mac-app-util, nix-homebrew, homebrew-core, homebrew-cask, homebrew-bundle, homebrew-services, ... }:
let
configuration = { pkgs, ... }: {
nixpkgs.config.allowUnfree = true;
# List packages installed in system profile. To search by name, run:
# $ nix-env -qaP | grep wget
environment.systemPackages = [
pkgs.git
pkgs.vim
pkgs.vscode
pkgs.iterm2
pkgs.wget
];
nixpkgs.config.allowBroken = true;
homebrew = {
enable = true;
# Uncomment to install cli packages from Homebrew.
# brews = [
# "mas"
# ];
# Uncomment to install cask packages from Homebrew.
casks = [
"balenaetcher"
"calibre"
"carbon-copy-cloner"
"logitech-options"
"zed"
];
# Uncomment to install app store apps using mas-cli.
# masApps = {
# "Session" = 1521432881;
# };
# Uncomment to remove any non-specified homebrew packages.
# onActivation.cleanUp = "zap";
# Uncomment to automatically update Homebrew and upgrade packages.
onActivation.autoUpdate = true;
onActivation.upgrade = true;
};
# Necessary for using flakes on this system.
nix.settings.experimental-features = "nix-command flakes";
# Enable alternative shell support in nix-darwin.
# programs.fish.enable = true;
programs.zsh.enable = true;
# Set Git commit hash for darwin-version.
system.configurationRevision = self.rev or self.dirtyRev or null;
# Used for backwards compatibility, please read the changelog before changing.
# $ darwin-rebuild changelog
system.stateVersion = 6;
# The platform the configuration will be used on.
nixpkgs.hostPlatform = "aarch64-darwin";
system.defaults = {
dock.autohide = true;
dock.magnification = false;
dock.mineffect = "genie";
finder.FXPreferredViewStyle = "clmv";
loginwindow.GuestEnabled = false;
NSGlobalDomain.AppleInterfaceStyle = "Dark";
NSGlobalDomain.KeyRepeat = 2;
};
};
in
{
# Build darwin flake using:
# $ darwin-rebuild build --flake .#simple
darwinConfigurations."simple" = nix-darwin.lib.darwinSystem {
modules = [
configuration
mac-app-util.darwinModules.default
nix-homebrew.darwinModules.nix-homebrew
{
nix-homebrew = {
# Install Homebrew under the default prefix
enable = true;
# Apple Silicon Only: Also install Homebrew under the default Intel prefix for Rosetta 2
enableRosetta = true;
# User owning the Homebrew prefix
user = "francisco";
# Optional: Declarative tap management
taps = {
"homebrew/homebrew-core" = homebrew-core;
"homebrew/homebrew-cask" = homebrew-cask;
"homebrew/homebrew-bundle" = homebrew-bundle;
"homebrew/homebrew-services" = homebrew-services;
};
# Optional: Enable fully-declarative tap management
#
# With mutableTaps disabled, taps can no longer be added imperatively with `brew tap`.
mutableTaps = false;
# Automatically migrate existing Homebrew installations
# autoMigrate = true;
};
}
];
};
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment