From d44a684fbbda55683cf2eca878df5fefb70be1dc Mon Sep 17 00:00:00 2001 From: Timo Bingmann Date: Mon, 11 Aug 2025 08:17:44 -0700 Subject: [PATCH] create tb-shared.nixosModules.macos --- flake.nix | 7 +++ system/macos/fonts.nix | 47 ++++++++++++++++++ system/macos/system.nix | 102 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 156 insertions(+) create mode 100644 system/macos/fonts.nix create mode 100644 system/macos/system.nix diff --git a/flake.nix b/flake.nix index e1abb47..32eda28 100644 --- a/flake.nix +++ b/flake.nix @@ -22,6 +22,13 @@ ]; }; + nixosModules.macos = { ... }: { + imports = [ + ./system/macos/system.nix + ./system/macos/fonts.nix + ]; + }; + # Home Manager Modules homeManagerModules.default = { ... }: { imports = [ diff --git a/system/macos/fonts.nix b/system/macos/fonts.nix new file mode 100644 index 0000000..631d421 --- /dev/null +++ b/system/macos/fonts.nix @@ -0,0 +1,47 @@ +{ pkgs, ... }: +{ + # Font configuration for MacOS + fonts = { + packages = with pkgs; [ + # Core fonts + dejavu_fonts + noto-fonts + noto-fonts-cjk-sans + noto-fonts-emoji + liberation_ttf + ubuntu_font_family + ubuntu-sans + ubuntu-classic + ubuntu-sans-mono + + fira + fira-code + fira-sans + fira-mono + inconsolata + + nerd-fonts.fantasque-sans-mono + nerd-fonts.hack + nerd-fonts.meslo-lg + + # Microsoft compatibility fonts + corefonts + vistafonts + + # Good programming fonts + jetbrains-mono + source-sans + source-sans-pro + source-code-pro + + # System fonts + freefont_ttf + + google-fonts + terminus_font + terminus_font_ttf + roboto + openmoji-color + ]; + }; +} diff --git a/system/macos/system.nix b/system/macos/system.nix new file mode 100644 index 0000000..3210451 --- /dev/null +++ b/system/macos/system.nix @@ -0,0 +1,102 @@ +{ ... }: +{ + system.defaults = { + dock = { + autohide = true; # Automatically hide and show the Dock + autohide-delay = 0.0; # Remove the delay for showing the Dock + autohide-time-modifier = 0.2; # Speed up the animation when hiding/showing the Dock + magnification = false; # Disable magnification on hover + mineffect = "scale"; # Set minimize animation to scale (faster than genie) + minimize-to-application = true; # Minimize windows into application icon + mru-spaces = false; # Don't automatically rearrange Spaces based on use + orientation = "bottom"; # Position the Dock at the bottom + show-process-indicators = true; # Show indicators for open applications + show-recents = false; # Don't show recent applications in Dock + showhidden = true; # Make hidden app icons translucent + static-only = false; # Show both static and recent apps + tilesize = 48; # Size of Dock icons + }; + + finder = { + AppleShowAllExtensions = true; # Always show file extensions + AppleShowAllFiles = true; # Show hidden files + FXDefaultSearchScope = "SCcf"; # Search current folder by default + FXEnableExtensionChangeWarning = false; # Disable warning when changing file extension + QuitMenuItem = true; # Allow quitting Finder via ⌘Q + ShowPathbar = true; # Show path bar at bottom of Finder windows + ShowStatusBar = true; # Show status bar at bottom of Finder windows + _FXShowPosixPathInTitle = true; # Show full POSIX path in window title + _FXSortFoldersFirst = true; # Keep folders on top when sorting + }; + + NSGlobalDomain = { + # Appearance + AppleInterfaceStyle = "Dark"; # Use dark mode + AppleInterfaceStyleSwitchesAutomatically = false; # Don't auto-switch appearance + + # Keyboard settings + AppleKeyboardUIMode = 3; # Full keyboard access for all controls + ApplePressAndHoldEnabled = false; # Disable press-and-hold for keys (enable key repeat) + KeyRepeat = 2; # Fast key repeat rates + InitialKeyRepeat = 10; # Short delay until key repeat starts + + # Text input settings + NSAutomaticCapitalizationEnabled = false; # Disable automatic capitalization + NSAutomaticDashSubstitutionEnabled = false; # Disable smart dashes + NSAutomaticPeriodSubstitutionEnabled = false; # Disable automatic period substitution + NSAutomaticQuoteSubstitutionEnabled = false; # Disable smart quotes + NSAutomaticSpellingCorrectionEnabled = false; # Disable automatic spelling correction + + # Save dialog settings + NSDocumentSaveNewDocumentsToCloud = false; # Save to disk by default, not iCloud + NSNavPanelExpandedStateForSaveMode = true; # Expand save panel by default + NSNavPanelExpandedStateForSaveMode2 = true; # Expand save panel by default (alternate) + + # Window and UI behavior + AppleShowScrollBars = "Automatic"; # Show scroll bars automatically + NSAutomaticWindowAnimationsEnabled = true; # Enable window animations + NSScrollAnimationEnabled = true; # Enable smooth scrolling + NSTableViewDefaultSizeMode = 2; # Set sidebar icon size to medium + NSWindowResizeTime = 0.001; # Speed up window resize animations + + # Other useful settings + AppleMeasurementUnits = "Centimeters"; # Use metric units + AppleMetricUnits = 1; # Enable metric units + AppleShowAllFiles = true; # Show hidden files globally + PMPrintingExpandedStateForPrint = true; # Expand print panel by default + "com.apple.mouse.tapBehavior" = 1; # Enable tap to click for mouse + "com.apple.swipescrolldirection" = false; # Natural scrolling direction + }; + + # Trackpad settings + trackpad = { + Clicking = true; # Enable tap to click + TrackpadThreeFingerDrag = true; # Enable three finger drag + ActuationStrength = 0; # Silent clicking + FirstClickThreshold = 1; # Light click pressure + SecondClickThreshold = 1; # Light force touch pressure + }; + + # Activity Monitor settings + ActivityMonitor = { + IconType = 5; # Show CPU usage in Dock icon + OpenMainWindow = true; # Show main window on launch + SortColumn = "CPUUsage"; # Sort by CPU usage + SortDirection = 0; # Sort descending + }; + }; + + # Keyboard settings + system.keyboard = { + enableKeyMapping = true; # Enable key remapping + remapCapsLockToControl = true; # Remap Caps Lock to Control + }; + + # Custom user preferences (these require logout/login to take effect) + system.startup.chime = false; # Disable startup sound + + system.activationScripts.postActivation.text = '' + # Following line should allow us to avoid a logout/login cycle when changing settings + sudo -u tbingmann /System/Library/PrivateFrameworks/SystemAdministration.framework/Resources/activateSettings -u + ''; +}