mirror of
https://github.com/nmasur/dotfiles
synced 2026-07-06 23:43:57 +00:00
switch from nix-darwin control to more home-manager darwin settings
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
cfg = config.nmasur.presets.services.darwin-settings;
|
||||
in
|
||||
|
||||
{
|
||||
|
||||
options.nmasur.presets.services.darwin-settings.enable = lib.mkEnableOption "macOS settings";
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
|
||||
targets.darwin.defaults = {
|
||||
NSGlobalDomain = {
|
||||
|
||||
# Set to dark mode
|
||||
AppleInterfaceStyle = "Dark";
|
||||
|
||||
# Don't change from dark to light automatically
|
||||
# AppleInterfaceSwitchesAutomatically = false;
|
||||
|
||||
# Enable full keyboard access for all controls (e.g. enable Tab in modal dialogs)
|
||||
AppleKeyboardUIMode = 3;
|
||||
|
||||
# Expand save panel by default
|
||||
NSNavPanelExpandedStateForSaveMode = true;
|
||||
|
||||
# Expand print panel by default
|
||||
PMPrintingExpandedStateForPrint = true;
|
||||
|
||||
# Replace press-and-hold with key repeat
|
||||
ApplePressAndHoldEnabled = false;
|
||||
|
||||
# Set a fast key repeat rate
|
||||
KeyRepeat = 2;
|
||||
|
||||
# Shorten delay before key repeat begins
|
||||
InitialKeyRepeat = 12;
|
||||
|
||||
# Disable autocorrect capitalization
|
||||
NSAutomaticCapitalizationEnabled = false;
|
||||
|
||||
# Disable autocorrect smart dashes
|
||||
NSAutomaticDashSubstitutionEnabled = false;
|
||||
|
||||
# Disable autocorrect adding periods
|
||||
NSAutomaticPeriodSubstitutionEnabled = false;
|
||||
|
||||
# Disable autocorrect smart quotation marks
|
||||
NSAutomaticQuoteSubstitutionEnabled = false;
|
||||
|
||||
# Disable autocorrect spellcheck
|
||||
NSAutomaticSpellingCorrectionEnabled = false;
|
||||
};
|
||||
|
||||
"com.apple.LaunchServices" = {
|
||||
# Disable "Are you sure you want to open" dialog
|
||||
LSQuarantine = false;
|
||||
};
|
||||
|
||||
# Where to save screenshots
|
||||
"com.apple.screencapture" = {
|
||||
location = "~/Downloads";
|
||||
};
|
||||
|
||||
# Disable disk image verification
|
||||
"com.apple.frameworks.diskimages" = {
|
||||
skip-verify = true;
|
||||
skip-verify-locked = true;
|
||||
skip-verify-remote = true;
|
||||
};
|
||||
# Require password immediately after screen saver begins
|
||||
"com.apple.screensaver" = {
|
||||
askForPassword = 1;
|
||||
askForPasswordDelay = 0;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
targets.darwin.currentHostDefaults = {
|
||||
"com.apple.mouse.tapBehavior" = {
|
||||
# Disable trackpad tap to click
|
||||
Clicking = false;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
cfg = config.nmasur.presets.services.dock;
|
||||
|
||||
# macOS stores persistent-apps as an array of dicts, not strings.
|
||||
# nix-darwin's dock module did this transform for us; targets.darwin.defaults
|
||||
# writes values verbatim, so we build the tile dicts ourselves.
|
||||
mkDockApp = path: {
|
||||
tile-data.file-data = {
|
||||
_CFURLString = path;
|
||||
_CFURLStringType = 0;
|
||||
};
|
||||
};
|
||||
in
|
||||
|
||||
{
|
||||
|
||||
options.nmasur.presets.services.dock.enable = lib.mkEnableOption "macOS Dock";
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
|
||||
targets.darwin.defaults = {
|
||||
"com.apple.dock" = {
|
||||
magnification = true;
|
||||
largesize = 48;
|
||||
|
||||
# Automatically show and hide the dock
|
||||
autohide = true;
|
||||
|
||||
# Add translucency in dock for hidden applications
|
||||
showhidden = true;
|
||||
|
||||
# Enable spring loading on all dock items
|
||||
enable-spring-load-actions-on-all-items = true;
|
||||
|
||||
# Highlight hover effect in dock stack grid view
|
||||
mouse-over-hilite-stack = true;
|
||||
|
||||
mineffect = "genie";
|
||||
orientation = "bottom";
|
||||
show-recents = false;
|
||||
tilesize = 44;
|
||||
|
||||
persistent-apps = map mkDockApp [
|
||||
"/Applications/1Password.app"
|
||||
"${pkgs.slack}/Applications/Slack.app"
|
||||
"/System/Applications/Calendar.app"
|
||||
"${pkgs.firefox-unwrapped}/Applications/Firefox.app"
|
||||
"/System/Applications/Messages.app"
|
||||
"/System/Applications/Mail.app"
|
||||
"/Applications/zoom.us.app"
|
||||
"${config.programs.ghostty.package}/Applications/Ghostty.app"
|
||||
"${pkgs.discord}/Applications/Discord.app"
|
||||
"${pkgs.obsidian}/Applications/Obsidian.app"
|
||||
"${pkgs.thunderbird}/Applications/Thunderbird.app"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
# Automatically reload the Dock and Finder when Home Manager switches
|
||||
home.activation = {
|
||||
reloadMacSettings = config.lib.dag.entryAfter [ "writeBoundary" ] ''
|
||||
verboseEcho "Restarting macOS desktop services..."
|
||||
run /usr/bin/killall Dock Finder || true
|
||||
'';
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
cfg = config.nmasur.presets.services.finder;
|
||||
in
|
||||
|
||||
{
|
||||
|
||||
options.nmasur.presets.services.finder.enable = lib.mkEnableOption "macOS Finder options";
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
targets.darwin.defaults = {
|
||||
"com.apple.finder" = {
|
||||
# Default Finder window set to column view
|
||||
FXPreferredViewStyle = "clmv";
|
||||
|
||||
# Finder search in current folder by default
|
||||
FXDefaultSearchScope = "SCcf";
|
||||
|
||||
# Disable warning when changing file extension
|
||||
FXEnableExtensionChangeWarning = false;
|
||||
|
||||
# Allow quitting of Finder application
|
||||
QuitMenuItem = true;
|
||||
|
||||
# Disable the warning before emptying the Trash
|
||||
WarnOnEmptyTrash = false;
|
||||
|
||||
};
|
||||
|
||||
NSGlobalDomain = {
|
||||
|
||||
# Save to local disk by default, not iCloud
|
||||
NSDocumentSaveNewDocumentsToCloud = false;
|
||||
|
||||
};
|
||||
|
||||
# Avoid creating .DS_Store files on network or USB volumes
|
||||
"com.apple.desktopservices" = {
|
||||
DSDontWriteNetworkStores = true;
|
||||
DSDontWriteUSBStores = true;
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
let
|
||||
cfg = config.nmasur.presets.services.hammerspoon;
|
||||
# inherit (config.nmasur.settings) username;
|
||||
in
|
||||
|
||||
{
|
||||
@@ -15,6 +16,17 @@ in
|
||||
lib.mkEnableOption "Hammerspoon macOS automation";
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
|
||||
home.file.".Brewfile".text = /* homebrew */ ''
|
||||
cask "hammerspoon" # Different scroll style for mouse vs. trackpad
|
||||
'';
|
||||
|
||||
targets.darwin.defaults = {
|
||||
"org.hammerspoon.Hammerspoon" = {
|
||||
MJConfigFile = "${config.xdg.configHome}/hammerspoon/init.lua";
|
||||
};
|
||||
};
|
||||
|
||||
xdg.configFile."hammerspoon/init.lua".source = ./init.lua;
|
||||
xdg.configFile."hammerspoon/Spoons/ControlEscape.spoon".source = ./Spoons/ControlEscape.spoon;
|
||||
xdg.configFile."hammerspoon/Spoons/DismissAlerts.spoon".source = ./Spoons/DismissAlerts.spoon;
|
||||
@@ -32,9 +44,18 @@ in
|
||||
xdg.configFile."hammerspoon/Spoons/HideZoomWindow.spoon".source = ./Spoons/HideZoomWindow.spoon;
|
||||
|
||||
home.activation.reloadHammerspoon = config.lib.dag.entryAfter [ "writeBoundary" ] ''
|
||||
$DRY_RUN_CMD /Applications/Hammerspoon.app/Contents/Frameworks/hs/hs -c "hs.reload()" || true
|
||||
$DRY_RUN_CMD sleep 1
|
||||
$DRY_RUN_CMD /Applications/Hammerspoon.app/Contents/Frameworks/hs/hs -c "hs.console.clearConsole()" || true
|
||||
# The `hs` CLI blocks forever on Hammerspoon's IPC message port when the
|
||||
# app isn't running (|| true can't help — it never returns). Only reload
|
||||
# when the app is actually up, and wrap each call in `timeout` as a hard
|
||||
# backstop so activation can never hang even if IPC is unresponsive.
|
||||
hs=/Applications/Hammerspoon.app/Contents/Frameworks/hs/hs
|
||||
if /usr/bin/pgrep -x Hammerspoon > /dev/null 2>&1; then
|
||||
$DRY_RUN_CMD ${pkgs.coreutils}/bin/timeout 10 "$hs" -c "hs.reload()" || true
|
||||
$DRY_RUN_CMD sleep 1
|
||||
$DRY_RUN_CMD ${pkgs.coreutils}/bin/timeout 10 "$hs" -c "hs.console.clearConsole()" || true
|
||||
else
|
||||
verboseEcho "Hammerspoon not running; skipping reload."
|
||||
fi
|
||||
'';
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
cfg = config.nmasur.presets.services.menubar;
|
||||
in
|
||||
|
||||
{
|
||||
|
||||
options.nmasur.presets.services.menubar.enable = lib.mkEnableOption "macOS menubar settings";
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
|
||||
home.packages = [
|
||||
pkgs.ice-bar # Menu bar hiding
|
||||
];
|
||||
|
||||
targets.darwin.defaults = {
|
||||
NSGlobalDomain = {
|
||||
|
||||
# Only hide menu bar in fullscreen
|
||||
_HIHideMenuBar = false;
|
||||
|
||||
NSStatusItemSelectionPadding = 6;
|
||||
NSStatusItemSpacing = 6;
|
||||
|
||||
};
|
||||
|
||||
"com.apple.menuextra.clock" = {
|
||||
# Show seconds on the clock
|
||||
ShowSeconds = true;
|
||||
|
||||
FlashDateSeparator = false;
|
||||
};
|
||||
|
||||
"leits.MeetingBar" = {
|
||||
eventTimeFormat = ''"show"'';
|
||||
eventTitleFormat = ''"none"'';
|
||||
eventTitleIconFormat = ''"iconCalendar"'';
|
||||
slackBrowser = ''{"deletable":true,"arguments":"","name":"Slack","path":""}'';
|
||||
zoomBrowser = ''{"deletable":true,"arguments":"","name":"Zoom","path":""}'';
|
||||
teamsBrowser = ''{"deletable":true,"arguments":"","name":"Teams","path":""}'';
|
||||
KeyboardShortcuts_joinEventShortcut = ''{"carbonModifiers":6400,"carbonKeyCode":38}'';
|
||||
timeFormat = ''"12-hour"'';
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user