{ pkgs, inputs, lib, ... }: let username = "ryan"; defaultBrowser = "zen"; pinnedNixpkgs = pkgs.writeText "flake-registry.json" (builtins.toJSON { version = 2; flakes = [ { from = { type = "indirect"; id = "nixpkgs"; }; to = { type = "path"; path = inputs.nixpkgs.outPath; lastModified = inputs.nixpkgs.lastModified; narHash = inputs.nixpkgs.narHash; }; } ]; }); mkSpace = i: { name = toString (117+i); value = { enabled = true; value = { type = "standard"; parameters = [ (48 + i) (builtins.elemAt [ 18 19 20 21 22 23 25 26 28 ] (i - 1)) 524288 ]; }; }; }; spaceHotkeys = builtins.listToAttrs (map mkSpace (lib.range 1 9)); manualHotkeys = { "64" = { enabled = true; }; }; in { # Modules imports = [ ../../modules/darwin/random-wallpaper.nix ]; # Define the system's user and home dir location users.users."${username}" = { name = "${username}"; home = "/Users/${username}"; }; system.primaryUser = "${username}"; # Install the wallpaper engine local.randomWallpaper = { enable = true; directory = "${../../files/Wallpapers}"; }; # Configure yabai services.yabai = { enable = true; enableScriptingAddition = false; config = { mouse_follows_focus = "on"; layout = "bsp"; window_placement = "second_child"; top_padding = "10"; bottom_padding = "10"; left_padding = "10"; right_padding = "10"; window_gap = "5"; mouse_modifier = "alt"; mouse_drop_action = "swap"; mouse_action1 = "move"; mouse_action2 = "resize"; focus_follows_mouse = "autofocus"; }; extraConfig = '' yabai -m rule --add app='System Settings' manage=off borders style=round active_color='gradient(top_left=0xee33ccff,bottom_right=0xee00ff99)' inactive_color=0xaa595959 width=6.0 ''; }; # Install the /etc/nix/flake-registry.json file we made above environment.etc."nix/flake-registry.json".source = pinnedNixpkgs; # Install RyanCA Root security.pki.certificateFiles = [ ../../files/CACerts/RyanCA.crt ]; # Need to disable native nix handling because of Determinate nix determinateNix = { enable = true; customSettings = { flake-registry = "/etc/nix/flake-registry.json"; }; }; # Determines the nix-darwin release compatibility system.stateVersion = 6; # System profile programs programs = { zsh.enable = true; }; # Install homebrew casks/apps homebrew = { enable = true; onActivation = { cleanup = "zap"; extraFlags = [ "--force-cleanup" ]; }; taps = [ "netbirdio/tap" "FelixKratz/formulae" ]; brews = [ "borders" ]; casks = [ "utm" "ghostty" "zen" "tailscale-app" "netbird-ui" ]; }; # Keyboard shortcuts using skhd services.skhd = { enable = true; skhdConfig = '' alt - d : osascript -e 'tell application "System Events" to key code 49 using {command down}' alt - return : osascript -e 'tell application "Ghostty"' -e 'new window' -e 'activate' -e 'end tell' alt - up : ${pkgs.yabai}/bin/yabai -m window --focus north shift + alt - up : ${pkgs.yabai}/bin/yabai -m window --swap north alt - down : ${pkgs.yabai}/bin/yabai -m window --focus south shift + alt - down : ${pkgs.yabai}/bin/yabai -m window --swap south alt - right : ${pkgs.yabai}/bin/yabai -m window --focus east shift + alt - right : ${pkgs.yabai}/bin/yabai -m window --swap east alt - left : ${pkgs.yabai}/bin/yabai -m window --focus west shift + alt - left: ${pkgs.yabai}/bin/yabai -m window --swap west shift + alt - 1 : ${pkgs.yabai}/bin/yabai -m window --space 1 shift + alt - 2 : ${pkgs.yabai}/bin/yabai -m window --space 2 shift + alt - 3 : ${pkgs.yabai}/bin/yabai -m window --space 3 shift + alt - 4 : ${pkgs.yabai}/bin/yabai -m window --space 4 shift + alt - 5 : ${pkgs.yabai}/bin/yabai -m window --space 5 shift + alt - 6 : ${pkgs.yabai}/bin/yabai -m window --space 6 shift + alt - 7 : ${pkgs.yabai}/bin/yabai -m window --space 7 shift + alt - 8 : ${pkgs.yabai}/bin/yabai -m window --space 8 shift + alt - 9 : ${pkgs.yabai}/bin/yabai -m window --space 9 alt - f : ${pkgs.yabai}/bin/yabai -m window --toggle zoom-fullscreen ''; }; # System configuration time.timeZone = "America/New_York"; power.sleep = { display = 10; computer = 30; }; system.defaults = { NSGlobalDomain = { # 24 hour time AppleICUForce24HourTime = true; # Dark Mode AppleInterfaceStyle = "Dark"; # Key repeat rate KeyRepeat = 4; InitialKeyRepeat = 30; # Swap F1-12 to be default "com.apple.keyboard.fnState" = true; # Disable Keyboard bullcrap NSAutomaticCapitalizationEnabled = false; NSAutomaticDashSubstitutionEnabled = false; NSAutomaticPeriodSubstitutionEnabled = false; NSAutomaticQuoteSubstitutionEnabled = false; NSAutomaticSpellingCorrectionEnabled = false; ApplePressAndHoldEnabled = false; }; # screensaver/power settings screensaver = { askForPassword = true; askForPasswordDelay = 0; }; # Control center stuff controlcenter = { BatteryShowPercentage = true; Bluetooth = true; }; # Clock settings menuExtraClock = { Show24Hour = true; ShowDate = 1; # Always ShowDayOfWeek = true; ShowSeconds = true; }; # Screen capture settings screencapture = { target = "clipboard"; type = "png"; }; # finder good settings finder = { AppleShowAllExtensions = true; AppleShowAllFiles = true; ShowPathbar = true; FXEnableExtensionChangeWarning = false; _FXShowPosixPathInTitle = true; NewWindowTarget = "Home"; ShowExternalHardDrivesOnDesktop = false; ShowHardDrivesOnDesktop = false; ShowMountedServersOnDesktop = false; ShowRemovableMediaOnDesktop = false; ShowStatusBar = true; }; spaces = { "spans-displays" = false; # independent spaces per display }; # Login Window Settings loginwindow = { GuestEnabled = false; DisableConsoleAccess = true; }; # dock settings dock = { magnification = true; largesize = 96; tilesize = 32; minimize-to-application = false; orientation = "bottom"; autohide = true; mru-spaces = false; # Disable auto-rearrange spaces persistent-apps = [ { app = "/Applications/Zen.app"; } #{ app = "/System/Applications/Launchpad.app"; } { app = "/System/Applications/Messages.app"; } { app = "/System/Applications/Facetime.app"; } { app = "/System/Applications/Calendar.app"; } { app = "/System/Applications/App Store.app"; } { app = "/System/Applications/System Settings.app"; } { app = "/Applications/UTM.app"; } ]; persistent-others = [ { folder = { path = "/Users/${username}/Downloads"; showas = "grid"; arrangement = "date-created"; }; } { folder = { path = "/Users/${username}/Applications"; showas = "grid"; arrangement = "name"; }; } ]; show-recents = false; }; # Custom preferences CustomUserPreferences = { NSGlobalDomain = { # Always show menu bar AppleMenuBarVisibleInFullscreen = true; # Option + L lock NSUserKeyEquivalents = { "Lock Screen" = "~l"; }; }; "com.apple.Accessibility" = { ReduceMotionEnabled = 1; }; "com.apple.symbolichotkeys" = { AppleSymbolicHotKeys = manualHotkeys // spaceHotkeys; }; }; universalaccess.reduceMotion = true; }; # Post-Activation scripts system.activationScripts.postActivation.text = '' echo "Configuring NTP servers..." systemsetup -setnetworktimeserver pool.ntp.org > /dev/null 2>&1 || true systemsetup -setusingnetworktime on > /dev/null 2>&1 || true ryancasum="$(${pkgs.openssl}/bin/openssl x509 -in "${../../files/CACerts/RyanCA.crt}" -noout -fingerprint -sha1 | sed 's/.*=//; s/://g')" if ! /usr/bin/security find-certificate -a -Z "/Library/Keychains/System.keychain" | tr -d ':' | grep -iq "$ryancasum"; then echo "Installing RyanCA Certificate..." /usr/bin/security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ${../../files/CACerts/RyanCA.crt} fi echo "Reloading Preferences DB..." sudo -iu ${username} /System/Library/PrivateFrameworks/SystemAdministration.framework/Resources/activateSettings -u echo "Setting default browser" ${pkgs.defaultbrowser}/bin/defaultbrowser ${defaultBrowser} echo "Adding Keyboard brightness controls to Control Center..." sudo -iu ${username} defaults -currentHost write com.apple.controlcenter KeyboardBrightness -int 25 # this is fragile so it goes at the bottom echo "Reloading skhd..." sudo -iu ${username} ${pkgs.skhd}/bin/skhd -r # Notes if we are running for the first time and writes a message for actions that may need to be done on macOS or linux MARK="/opt/.nix-complete" if [ ! -f "$MARK" ]; then echo "o0o0o0o0o0o MacOS Initial Deploy Notes o0o0o0o0o0o" echo "--------------------------------------------------" echo "The following actions must be taken since they are not configurable by Nix. This must be done only ONCE." echo "" echo "1. Create 9 spaces." echo "2. Set a wallpaper as visible in all spaces." echo "--------------------------------------------------" fi touch "$MARK" ''; }