feat: nix-darwin-kickstarter minimal

This commit is contained in:
Sangmin Kim 2026-03-04 18:02:39 +09:00 committed by Poby
parent 5e30ed38cd
commit 248170c877
No known key found for this signature in database
9 changed files with 111 additions and 289 deletions

BIN
.DS_Store vendored

Binary file not shown.

63
flake.lock generated
View file

@ -1,63 +0,0 @@
{
"nodes": {
"darwin": {
"inputs": {
"nixpkgs": [
"nixpkgs-darwin"
]
},
"locked": {
"lastModified": 1758102940,
"narHash": "sha256-wwqf3+A8EiqwWpcAaPN20QXJLlpGPpwtLTrzgnngI2o=",
"owner": "lnl7",
"repo": "nix-darwin",
"rev": "ebd0bfc11fc2b5cff37401e9b3703881ad5fabbd",
"type": "github"
},
"original": {
"owner": "lnl7",
"repo": "nix-darwin",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1758262103,
"narHash": "sha256-aBGl3XEOsjWw6W3AHiKibN7FeoG73dutQQEqnd/etR8=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "12bd230118a1901a4a5d393f9f56b6ad7e571d01",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"nixpkgs-darwin": {
"locked": {
"lastModified": 1758262103,
"narHash": "sha256-aBGl3XEOsjWw6W3AHiKibN7FeoG73dutQQEqnd/etR8=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "12bd230118a1901a4a5d393f9f56b6ad7e571d01",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"darwin": "darwin",
"nixpkgs": "nixpkgs",
"nixpkgs-darwin": "nixpkgs-darwin"
}
}
},
"root": "root",
"version": 7
}

View file

@ -1,29 +1,21 @@
{ {
description = "Nix for macOS configuration"; description = "Nix for Poby's MacOS";
################################################################################################################## nixConfig = {
# substituters = [ "https://cache.nixos.org" ];
# Want to know Nix in details? Looking for a beginner-friendly tutorial? };
# Check out https://github.com/ryan4yin/nixos-and-flakes-book !
#
##################################################################################################################
# This is the standard format for flake.nix. `inputs` are the dependencies of the flake, inputs = let
# Each item in `inputs` will be passed as a parameter to the `outputs` function after being pulled and built. stableVersion = "25.11"; # FIXME to bump to latest stable version
inputs = { in {
nixpkgs-darwin.url = "github:nixos/nixpkgs/nixpkgs-unstable"; # nixpkgs-darwin.url = "github:nixos/nixpkgs/nixpkgs-unstable"; # comment out for unstable version
# nixpkgs-darwin.url = "github:nixos/nixpkgs/nixpkgs-24.05-darwin"; nixpkgs-darwin.url = "github:nixos/nixpkgs/nixpkgs-${stableVersion}-darwin";
darwin = { darwin = {
url = "github:lnl7/nix-darwin"; url = "github:lnl7/nix-darwin/nix-darwin-${stableVersion}";
inputs.nixpkgs.follows = "nixpkgs-darwin"; inputs.nixpkgs.follows = "nixpkgs-darwin";
}; };
}; };
# The `outputs` function will return all the build results of the flake.
# A flake can have many use cases and different types of outputs,
# parameters in `outputs` are defined in `inputs` and can be referenced by their names.
# However, `self` is an exception, this special parameter points to the `outputs` itself (self-reference)
# The `@` syntax here is used to alias the attribute set of the inputs's parameter, making it convenient to use inside the function.
outputs = inputs @ { outputs = inputs @ {
self, self,
nixpkgs, nixpkgs,
@ -32,7 +24,7 @@
}: let }: let
username = "poby"; username = "poby";
system = "aarch64-darwin"; system = "aarch64-darwin";
hostname = "pobys-macbook-pro"; hostname = "fenrir"; # TODO break down to multiple hosts
specialArgs = specialArgs =
inputs inputs
@ -49,7 +41,6 @@
./modules/host-users.nix ./modules/host-users.nix
]; ];
}; };
# nix code formatter
formatter.${system} = nixpkgs.legacyPackages.${system}.alejandra; formatter.${system} = nixpkgs.legacyPackages.${system}.alejandra;
}; };
} }

BIN
modules/.DS_Store vendored

Binary file not shown.

View file

@ -1,116 +1,46 @@
{ pkgs, ... }: { { pkgs, ... }: {
##########################################################################
#
# Install all apps and packages here.
#
##########################################################################
# Install packages from nix's official package repository.
#
# The packages installed here are available to all users, and are reproducible across machines, and are rollbackable.
# But on macOS, it's less stable than homebrew.
#
# Related Discussion: https://discourse.nixos.org/t/darwin-again/29331
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
# CLI
git git
just # use Justfile to simplify nix-darwin's commands just # use Justfile to simplify nix-darwin's commands
ffmpeg vim
fzf curl
bat
fastfetch
gh
lsd
mkalias
python310
tldr
tmux
tree
zoxide
zsh-powerlevel10k
zsh-fzf-tab
commitizen
]; ];
environment.variables.EDITOR = "nvim";
# TODO To make this work, homebrew need to be installed manually, see https://brew.sh
#
# The apps installed by homebrew are not managed by nix, and not reproducible!
# But on macOS, homebrew has a much larger selection of apps than nixpkgs, especially for GUI apps!
homebrew = { homebrew = {
enable = true; enable = true;
onActivation = { onActivation = {
autoUpdate = true; # Fetch the newest stable branch of Homebrew's git repo autoUpdate = true;
upgrade = true; # Upgrade outdated casks, formulae, and App Store apps
# 'zap': uninstalls all formulae(and related files) not listed in the generated Brewfile
cleanup = "zap"; cleanup = "zap";
}; };
# Applications to install from Mac App Store using mas. # Applications to install from Mac App Store using mas.
# You need to install all these Apps manually first so that your apple account have records for them.
# otherwise Apple Store will refuse to install them.
# For details, see https://github.com/mas-cli/mas
masApps = { masApps = {
KakaoTalk = 869223134; KakaoTalk = 869223134;
Across = 6444851827; Across = 6444851827;
Flighty = 1358823008;
Numbers = 409203825;
Pages = 409201541;
Keynote = 409183694;
Bitwarden = 1352778147; Bitwarden = 1352778147;
}; };
taps = [ ]; taps = [ ];
# `brew install` # WARNING only include those not in nixpkgs
brews = [ brews = [
"wget" # "neovim"
"curl" # do not install curl via nixpkgs, it's not working well on macOS! # "ripgrep"
"nvm" # "fd"
"uv"
"openjdk"
"openjdk@21"
"openjdk@17"
"neovim"
"ripgrep"
"tree-sitter"
]; ];
# `brew install --cask`
casks = [ casks = [
"alt-tab"
"bruno"
"discord"
"google-chrome"
"iina"
"intellij-idea"
"jordanbaird-ice"
"keka"
"raycast"
"rectangle"
"slack"
"stats"
"telegram"
"visual-studio-code"
"zoom"
"claude"
"batfi" "batfi"
"docker-desktop"
"cursor"
"daisydisk"
"ghostty"
"hammerspoon" "hammerspoon"
"hancom-docs" # "google-chrome"
"logi-options+" # "iina"
"notion" # "jordanbaird-ice"
"onyx" # "keka"
"shottr" # "shottr"
"arc" # "raycast"
"obsidian" # "stats"
"antigravity"
"figma"
# Fonts # Fonts
"font-fontawesome" "font-fontawesome"
@ -121,6 +51,7 @@
"font-symbols-only-nerd-font" "font-symbols-only-nerd-font"
"font-material-design-icons-webfont" "font-material-design-icons-webfont"
"font-pretendard" "font-pretendard"
"font-maple-mono-nf"
]; ];
}; };
} }

View file

@ -1,23 +1,12 @@
{ { username, hostname, ... }:
username,
hostname,
...
} @ args:
#############################################################
#
# Host & Users configuration
#
#############################################################
{ {
networking.hostName = hostname; networking.hostName = hostname;
networking.computerName = hostname; networking.computerName = hostname;
system.defaults.smb.NetBIOSName = hostname;
# Define a user account. Don't forget to set a password with passwd.
users.users."${username}" = { users.users."${username}" = {
home = "/Users/${username}"; home = "/Users/${username}";
description = username; description = username;
}; };
nix.settings.trusted-users = [username]; nix.settings.trusted-users = [ username ];
} }

View file

@ -1,20 +1,22 @@
{ pkgs, ... }: { pkgs, lib, ... }:
{ {
nix.settings = { nix = {
# enable flakes globally enable = true;
experimental-features = ["nix-command" "flakes"]; package = pkgs.nix;
settings = {
experimental-features = [ "nix-command" "flakes" ];
substituters = [ "https://nix-community.cachix.org" ];
trusted-public-keys = [
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
];
builders-user-substitutes = true;
auto-optimise-store = false; # issue https://github.com/NixOS/nix/issues/7273
};
}; };
# Allow unfree packages gc = {
nixpkgs.config = { automatic = lib.mkDefault true;
allowUnfree = true; options = lib.mkDefault "--delete-older-than 7d";
allowBroken = true;
}; };
# Auto upgrade nix package and the daemon service.
nix.package = pkgs.nix;
# Enable Determinate
nix.enable = false;
} }

View file

@ -1,21 +1,10 @@
{ pkgs, config, username, ... }: { pkgs, config, username, hostname, ... }:
###################################################################################
#
# macOS's System configuration
#
# All the configuration options are documented here:
# https://daiderd.com/nix-darwin/manual/index.html#sec-options
# Incomplete list of macOS `defaults` commands :
# https://github.com/yannbertrand/macos-defaults
#
###################################################################################
{ {
system = { system = {
primaryUser = username; primaryUser = username;
stateVersion = 6; stateVersion = 6;
# activationScripts are executed every time you boot the system or run `nixos-rebuild` / `darwin-rebuild`.
activationScripts.extraActivation.text = '' activationScripts.extraActivation.text = ''
# activateSettings -u will reload the settings from the database and apply them to the current session, # activateSettings -u will reload the settings from the database and apply them to the current session,
# so we do not need to logout and login again to make the changes take effect. # so we do not need to logout and login again to make the changes take effect.
@ -43,13 +32,11 @@
''; '';
defaults = { defaults = {
# login window
loginwindow = { loginwindow = {
GuestEnabled = false; # disable guest user GuestEnabled = false;
SHOWFULLNAME = true; # show full name in login window
}; };
# control center
controlcenter = { controlcenter = {
Sound = false; Sound = false;
Bluetooth = false; Bluetooth = false;
@ -58,14 +45,11 @@
NowPlaying = false; NowPlaying = false;
}; };
# clock
menuExtraClock = { menuExtraClock = {
Show24Hour = true; Show24Hour = true;
ShowAMPM = false;
ShowDayOfWeek = false; ShowDayOfWeek = false;
}; };
# dock
dock = { dock = {
autohide = true; autohide = true;
autohide-delay = 0.01; autohide-delay = 0.01;
@ -75,38 +59,69 @@
tilesize = 50; tilesize = 50;
magnification = true; magnification = true;
largesize = 70; largesize = 70;
wvous-bl-corner = 11; showMissionControlGestureEnabled = true;
}; };
# finder
finder = { finder = {
AppleShowAllFiles = true; AppleShowAllFiles = true;
AppleShowAllExtensions = true;
ShowStatusBar = true; ShowStatusBar = true;
ShowPathbar = true; ShowPathbar = true;
FXPreferredViewStyle = "Nlsv"; FXPreferredViewStyle = "clmv";
AppleShowAllExtensions = true; FXRemoveOldTrashItems = true;
QuitMenuItem = true; _FXEnableColumnAutoSizing = true;
_FXShowPosixPathInTitle = true; _FXShowPosixPathInTitle = true;
_FXSortFoldersFirst = true; _FXSortFoldersFirst = true;
_FXSortFoldersFirstOnDesktop = true;
FXEnableExtensionChangeWarning = false; FXEnableExtensionChangeWarning = false;
NewWindowTarget = "Home"; FXDefaultSearchScope = "SCcf";
NewWindowTarget = "Other";
NewWindowTargetPath = "/Users/${username}/Downloads";
ShowExternalHardDrivesOnDesktop = true;
ShowHardDrivesOnDesktop = true;
ShowMountedServersOnDesktop = true;
ShowRemovableMediaOnDesktop = true;
QuitMenuItem = true;
}; };
# trackpad
trackpad = { trackpad = {
Clicking = true; Clicking = true;
TrackpadRightClick = true; # enable two finger right click TrackpadRightClick = true; # two finger right click
TrackpadThreeFingerDrag = true; # enable three finger drag TrackpadThreeFingerDrag = true;
TrackpadFourFingerHorizSwipeGesture = 2; # swipe between full-screen applications
TrackpadFourFingerVertSwipeGesture = 2; # down for Mission Control, up for App Expose
TrackpadPinch = true;
TrackpadThreeFingerHorizSwipGesture = 0; # disable for three finger drag
TrackpadThreeFingerVertSwipeGesture = 0; # disable for three finger drag
TrackpadTwoFingerDoubleTapGesture = true; # smart zoom
TrackpadTwoFingerFromRightEdgeSwipeGesture = 0;
}; };
# customize settings that not supported by nix-darwin directly screensaver = {
# Incomplete list of macOS `defaults` commands : askForPassword = true;
# https://github.com/yannbertrand/macos-defaults askForPasswordDelay = 0;
};
smb = {
NetBIOSName = hostname;
ServerDescription = hostname;
};
WindowManager = {
AppWindowGroupingBehavior = true;
EnableStandardClickToShowDesktop = false;
EnableTilingByEdgeDrag = false;
EnableTilingOptionAccelerator = false;
EnableTopTilingByEdgeDrag = false;
StandardHideDesktopIcons = true;
StandardHideWidgets = true;
};
# Customize settings that not supported by nix-darwin directly
# source: https://github.com/yannbertrand/macos-defaults
NSGlobalDomain = { NSGlobalDomain = {
# `defaults read NSGlobalDomain "xxx"`
"com.apple.swipescrolldirection" = true;
AppleInterfaceStyle = "Dark"; AppleInterfaceStyle = "Dark";
AppleKeyboardUIMode = 3; AppleKeyboardUIMode = 2;
ApplePressAndHoldEnabled = false; ApplePressAndHoldEnabled = false;
InitialKeyRepeat = 15; InitialKeyRepeat = 15;
KeyRepeat = 2; KeyRepeat = 2;
@ -115,6 +130,7 @@
AppleScrollerPagingBehavior = true; AppleScrollerPagingBehavior = true;
AppleEnableMouseSwipeNavigateWithScrolls = true; AppleEnableMouseSwipeNavigateWithScrolls = true;
AppleEnableSwipeNavigateWithScrolls = true; AppleEnableSwipeNavigateWithScrolls = true;
AppleSpacesSwitchOnActivate = true;
NSAutomaticCapitalizationEnabled = false; NSAutomaticCapitalizationEnabled = false;
NSAutomaticDashSubstitutionEnabled = false; NSAutomaticDashSubstitutionEnabled = false;
@ -129,46 +145,11 @@
}; };
# Customize settings that not supported by nix-darwin directly # Customize settings that not supported by nix-darwin directly
# see the source code of this project to get more undocumented options: CustomSystemPreferences = {
# https://github.com/rgcr/m-cli
#
# All custom entries can be found by running `defaults read` command.
# or `defaults read xxx` to read a specific domain.
CustomUserPreferences = {
".GlobalPreferences" = {
# automatically switch to a new space when switching to the application
AppleSpacesSwitchOnActivate = true;
};
NSGlobalDomain = {
# Add a context menu item for showing the Web Inspector in web views
WebKitDeveloperExtras = true;
};
"com.apple.finder" = {
ShowExternalHardDrivesOnDesktop = true;
ShowHardDrivesOnDesktop = true;
ShowMountedServersOnDesktop = true;
ShowRemovableMediaOnDesktop = true;
_FXSortFoldersFirst = true;
# When performing a search, search the current folder by default
FXDefaultSearchScope = "SCcf";
};
"com.apple.desktopservices" = { "com.apple.desktopservices" = {
# Avoid creating .DS_Store files on network or USB volumes
DSDontWriteNetworkStores = true; DSDontWriteNetworkStores = true;
DSDontWriteUSBStores = true; DSDontWriteUSBStores = true;
}; };
"com.apple.WindowManager" = {
EnableStandardClickToShowDesktop = 0; # Click wallpaper to reveal desktop
StandardHideDesktopIcons = 0; # Show items on desktop
HideDesktop = 0; # Do not hide items on desktop & stage manager
StageManagerHideWidgets = 0;
StandardHideWidgets = 0;
};
"com.apple.screensaver" = {
# Require password immediately after sleep or screen saver begins
askForPassword = 1;
askForPasswordDelay = 0;
};
"com.apple.AdLib" = { "com.apple.AdLib" = {
allowApplePersonalizedAdvertising = false; allowApplePersonalizedAdvertising = false;
}; };
@ -182,15 +163,8 @@
}; };
}; };
# keyboard settings is not very useful on macOS
# the most important thing is to remap option key to alt key globally,
# but it's not supported by macOS yet.
keyboard = { keyboard = {
enableKeyMapping = true; # enable key mapping so that we can use `option` as `control` enableKeyMapping = true; # enable key mapping so that we can use `option` as `control`
# NOTE: do NOT support remap capslock to both control and escape at the same time
remapCapsLockToControl = false; # remap caps lock to control, useful for emac users
remapCapsLockToEscape = false; # remap caps lock to escape, useful for vim users
}; };
}; };
@ -208,7 +182,6 @@
enableFzfGit = true; enableFzfGit = true;
enableFzfHistory = true; enableFzfHistory = true;
promptInit = '' promptInit = ''
fastfetch
source ${pkgs.zsh-powerlevel10k}/share/zsh-powerlevel10k/powerlevel10k.zsh-theme source ${pkgs.zsh-powerlevel10k}/share/zsh-powerlevel10k/powerlevel10k.zsh-theme
source ${pkgs.zsh-fzf-tab}/share/fzf-tab/fzf-tab.plugin.zsh source ${pkgs.zsh-fzf-tab}/share/fzf-tab/fzf-tab.plugin.zsh
''; '';

1
result
View file

@ -1 +0,0 @@
/nix/store/wqavdqq4f3j9gwymsj724hz9jkjwa3gf-darwin-system-25.05.73d5958