mirror of
https://github.com/smg1024/nix-darwin.git
synced 2026-05-22 20:32:59 +09:00
270 lines
8.9 KiB
Nix
270 lines
8.9 KiB
Nix
{ pkgs, config, ... }:
|
|
|
|
###################################################################################
|
|
#
|
|
# 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 = {
|
|
stateVersion = 5;
|
|
# activationScripts are executed every time you boot the system or run `nixos-rebuild` / `darwin-rebuild`.
|
|
activationScripts.postUserActivation.text = ''
|
|
# 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.
|
|
/System/Library/PrivateFrameworks/SystemAdministration.framework/Resources/activateSettings -u
|
|
'';
|
|
|
|
activationScripts.extraActivation.text = ''
|
|
ln -sf "${pkgs.jdk11}/zulu-11.jdk" "/Library/Java/JavaVirtualMachines/"
|
|
ln -sf "${pkgs.jdk17}/zulu-17.jdk" "/Library/Java/JavaVirtualMachines/"
|
|
ln -sf "${pkgs.jdk}/zulu-21.jdk" "/Library/Java/JavaVirtualMachines/"
|
|
'';
|
|
|
|
activationScripts.applications.text = let
|
|
env = pkgs.buildEnv {
|
|
name = "system-applications";
|
|
paths = config.environment.systemPackages;
|
|
pathsToLink = "/Applications";
|
|
};
|
|
in
|
|
pkgs.lib.mkForce ''
|
|
# Set up applications.
|
|
echo "setting up /Applications..." >&2
|
|
rm -rf /Applications/Nix\ Apps
|
|
mkdir -p /Applications/Nix\ Apps
|
|
find ${env}/Applications -maxdepth 1 -type l -exec readlink '{}' + |
|
|
while read -r src; do
|
|
app_name=$(basename "$src")
|
|
echo "copying $src" >&2
|
|
${pkgs.mkalias}/bin/mkalias "$src" "/Applications/Nix Apps/$app_name"
|
|
done
|
|
'';
|
|
|
|
defaults = {
|
|
# login window
|
|
loginwindow = {
|
|
GuestEnabled = false; # disable guest user
|
|
SHOWFULLNAME = true; # show full name in login window
|
|
};
|
|
|
|
# control center
|
|
controlcenter = {
|
|
Sound = false;
|
|
Bluetooth = false;
|
|
AirDrop = false;
|
|
Display = false;
|
|
NowPlaying = false;
|
|
};
|
|
|
|
# clock
|
|
menuExtraClock = {
|
|
Show24Hour = true;
|
|
ShowAMPM = false;
|
|
ShowDayOfWeek = false;
|
|
};
|
|
|
|
# dock
|
|
dock = {
|
|
autohide = true;
|
|
autohide-delay = 0.01;
|
|
autohide-time-modifier = 0.1;
|
|
mineffect = "suck";
|
|
show-recents = false;
|
|
tilesize = 50;
|
|
magnification = true;
|
|
largesize = 70;
|
|
wvous-bl-corner = 11;
|
|
};
|
|
|
|
# finder
|
|
finder = {
|
|
AppleShowAllFiles = true;
|
|
ShowStatusBar = true;
|
|
ShowPathbar = true;
|
|
FXPreferredViewStyle = "Nlsv";
|
|
AppleShowAllExtensions = true;
|
|
QuitMenuItem = true;
|
|
_FXShowPosixPathInTitle = true;
|
|
_FXSortFoldersFirst = true;
|
|
FXEnableExtensionChangeWarning = false;
|
|
NewWindowTarget = "Home";
|
|
};
|
|
|
|
# trackpad
|
|
trackpad = {
|
|
Clicking = true;
|
|
TrackpadRightClick = true; # enable two finger right click
|
|
TrackpadThreeFingerDrag = true; # enable three finger drag
|
|
};
|
|
|
|
# customize settings that not supported by nix-darwin directly
|
|
# Incomplete list of macOS `defaults` commands :
|
|
# https://github.com/yannbertrand/macos-defaults
|
|
NSGlobalDomain = {
|
|
# `defaults read NSGlobalDomain "xxx"`
|
|
"com.apple.swipescrolldirection" = true;
|
|
AppleInterfaceStyle = "Dark";
|
|
AppleKeyboardUIMode = 3;
|
|
ApplePressAndHoldEnabled = false;
|
|
InitialKeyRepeat = 15;
|
|
KeyRepeat = 2;
|
|
|
|
AppleShowScrollBars = "WhenScrolling";
|
|
AppleScrollerPagingBehavior = true;
|
|
AppleEnableMouseSwipeNavigateWithScrolls = true;
|
|
AppleEnableSwipeNavigateWithScrolls = true;
|
|
|
|
NSAutomaticCapitalizationEnabled = false;
|
|
NSAutomaticDashSubstitutionEnabled = false;
|
|
NSAutomaticPeriodSubstitutionEnabled = false;
|
|
NSAutomaticQuoteSubstitutionEnabled = false;
|
|
NSAutomaticSpellingCorrectionEnabled = false;
|
|
NSNavPanelExpandedStateForSaveMode = true;
|
|
NSNavPanelExpandedStateForSaveMode2 = true;
|
|
NSTableViewDefaultSizeMode = 2;
|
|
|
|
"com.apple.keyboard.fnState" = true;
|
|
};
|
|
|
|
# Customize settings that not supported by nix-darwin directly
|
|
# see the source code of this project to get more undocumented options:
|
|
# 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" = {
|
|
# Avoid creating .DS_Store files on network or USB volumes
|
|
DSDontWriteNetworkStores = 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" = {
|
|
allowApplePersonalizedAdvertising = false;
|
|
};
|
|
# Prevent Photos from opening automatically when devices are plugged in
|
|
"com.apple.ImageCapture".disableHotPlug = true;
|
|
"com.apple.dock" = {
|
|
springboard-columns = 10;
|
|
springboard-rows = 10;
|
|
ResetLaunchPad = true;
|
|
};
|
|
};
|
|
};
|
|
|
|
# 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 = {
|
|
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
|
|
};
|
|
};
|
|
|
|
# Add ability to used TouchID for sudo authentication
|
|
security.pam.services.sudo_local.touchIdAuth = true;
|
|
|
|
# Create /etc/zshrc that loads the nix-darwin environment.
|
|
# this is required if you want to use darwin's default shell - zsh
|
|
programs.zsh = {
|
|
enable = true;
|
|
enableCompletion = true;
|
|
enableFastSyntaxHighlighting = true;
|
|
enableFzfCompletion = true;
|
|
enableFzfGit = true;
|
|
enableFzfHistory = true;
|
|
promptInit = ''
|
|
fastfetch
|
|
source ${pkgs.zsh-powerlevel10k}/share/zsh-powerlevel10k/powerlevel10k.zsh-theme
|
|
source ${pkgs.zsh-fzf-tab}/share/fzf-tab/fzf-tab.plugin.zsh
|
|
'';
|
|
};
|
|
|
|
environment = {
|
|
shells = [
|
|
pkgs.zsh
|
|
];
|
|
shellAliases = {
|
|
ls = "lsd --color=auto";
|
|
l = "lsd -lhG";
|
|
lt = "l --tree";
|
|
ll = "lsd -alhG";
|
|
lh = "lsd -dl .*";
|
|
lsd = "lsd --group-directories-first";
|
|
filecount="find . -type f | wc -l";
|
|
cat = "bat --color=always";
|
|
man = "tldr";
|
|
nixrebuild = "darwin-rebuild switch --flake ~/.config/nix-darwin";
|
|
nixupgrade = "cd ~/.config/nix-darwin && nix flake update";
|
|
nixconfig = "code ~/.config/nix-darwin";
|
|
sshconfig = "code ~/.ssh/config";
|
|
|
|
# git
|
|
g = "git";
|
|
gaa = "git add --all";
|
|
gcm = "git commit -m";
|
|
gca = "git commit --amend";
|
|
gst = "git status";
|
|
gco = "git checkout";
|
|
gl = "git pull";
|
|
gp = "git push";
|
|
glg = "git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' --date=short";
|
|
};
|
|
};
|
|
|
|
# Set your time zone.
|
|
time.timeZone = "Asia/Seoul";
|
|
|
|
# Fonts
|
|
fonts = {
|
|
packages = with pkgs; [
|
|
# icon fonts
|
|
material-design-icons
|
|
font-awesome
|
|
|
|
# nerdfonts
|
|
nerd-fonts.symbols-only
|
|
nerd-fonts.meslo-lg
|
|
nerd-fonts.d2coding
|
|
nerd-fonts.fira-code
|
|
nerd-fonts.jetbrains-mono
|
|
];
|
|
};
|
|
}
|