Migration
This is my new public git source viewer. Source available. Please contact with concerns/bugs.
Contact me
hosts/RyanMac/configuration.nix
da8261b3230a640dec8b8776103a6b361362111f
· 9.9 KB · 373 lines
raw
| 1 | { config, pkgs, inputs, lib, ... }: |
| 2 | let |
| 3 | username = "ryan"; |
| 4 | |
| 5 | defaultBrowser = "zen"; |
| 6 | |
| 7 | thirdPartyTaps = { |
| 8 | "netbirdio/homebrew-tap" = inputs.homebrew-netbird; |
| 9 | "FelixKratz/homebrew-formulae" = inputs.homebrew-felixkratz; |
| 10 | }; |
| 11 | |
| 12 | pinnedNixpkgs = pkgs.writeText "flake-registry.json" (builtins.toJSON { |
| 13 | version = 2; |
| 14 | flakes = [ |
| 15 | { |
| 16 | from = { type = "indirect"; id = "nixpkgs"; }; |
| 17 | to = { |
| 18 | type = "path"; |
| 19 | path = inputs.nixpkgs.outPath; |
| 20 | lastModified = inputs.nixpkgs.lastModified; |
| 21 | narHash = inputs.nixpkgs.narHash; |
| 22 | }; |
| 23 | } |
| 24 | ]; |
| 25 | }); |
| 26 | |
| 27 | manualHotkeys = { |
| 28 | "64" = { |
| 29 | enabled = true; |
| 30 | }; |
| 31 | }; |
| 32 | |
| 33 | in { |
| 34 | # Modules |
| 35 | imports = [ |
| 36 | inputs.nix-homebrew.darwinModules.nix-homebrew |
| 37 | ../../modules/darwin/random-wallpaper |
| 38 | ../../modules/darwin/yabai |
| 39 | ]; |
| 40 | |
| 41 | # Define the system's user and home dir location |
| 42 | users.users."${username}" = { |
| 43 | name = "${username}"; |
| 44 | home = "/Users/${username}"; |
| 45 | }; |
| 46 | |
| 47 | system.primaryUser = "${username}"; |
| 48 | |
| 49 | # Set the hostname for this machine |
| 50 | networking.hostName = "RyanMac"; |
| 51 | |
| 52 | # Install the wallpaper engine |
| 53 | local.randomWallpaper = { |
| 54 | enable = true; |
| 55 | directory = "${../../files/Wallpapers}"; |
| 56 | }; |
| 57 | |
| 58 | # Configure yabai |
| 59 | local.yabai = { |
| 60 | enable = true; |
| 61 | defaultPadding = 10; |
| 62 | defaultTopPadding = 40; |
| 63 | displayTopPadding = { |
| 64 | "37D8832A-2D66-02CA-B9F7-8F30A301B230" = 10; # macOS retina display |
| 65 | }; |
| 66 | extraSymbolicHotkeys = manualHotkeys; |
| 67 | }; |
| 68 | |
| 69 | # Configure JankyBorders |
| 70 | services.jankyborders = { |
| 71 | enable = true; |
| 72 | style = "round"; |
| 73 | width = 6.0; |
| 74 | hidpi = true; |
| 75 | ax_focus = true; |
| 76 | active_color = "gradient(top_left=0xee33ccff,bottom_right=0xee00ff99)"; |
| 77 | inactive_color = "0xaa595959"; |
| 78 | }; |
| 79 | |
| 80 | # Install the /etc/nix/flake-registry.json file we made above |
| 81 | environment.etc."nix/flake-registry.json".source = pinnedNixpkgs; |
| 82 | |
| 83 | # Install RyanCA Root |
| 84 | security.pki.certificateFiles = [ |
| 85 | ../../files/CACerts/RyanCA.crt |
| 86 | ]; |
| 87 | |
| 88 | # Virby linux builder |
| 89 | services.virby = { |
| 90 | enable = true; |
| 91 | cores = 4; |
| 92 | diskSize = "50GiB"; |
| 93 | onDemand = { |
| 94 | enable = true; |
| 95 | ttl = 30; |
| 96 | }; |
| 97 | rosetta = true; |
| 98 | }; |
| 99 | |
| 100 | nix = { |
| 101 | enable = true; |
| 102 | settings = { |
| 103 | flake-registry = "/etc/nix/flake-registry.json"; |
| 104 | extra-substituters = [ |
| 105 | "https://virby-nix-darwin.cachix.org" |
| 106 | ]; |
| 107 | extra-trusted-public-keys = [ |
| 108 | "virby-nix-darwin.cachix.org-1:z9GiEZeBU5bEeoDQjyfHPMGPBaIQJOOvYOOjGMKIlLo=" |
| 109 | ]; |
| 110 | "extra-experimental-features" = [ "nix-command" "flakes" ]; |
| 111 | }; |
| 112 | }; |
| 113 | |
| 114 | # Determines the nix-darwin release compatibility |
| 115 | system.stateVersion = 6; |
| 116 | |
| 117 | # System profile programs |
| 118 | programs = { |
| 119 | zsh.enable = true; |
| 120 | }; |
| 121 | |
| 122 | # Install homebrew itself |
| 123 | nix-homebrew = { |
| 124 | enable = true; |
| 125 | enableRosetta = true; |
| 126 | user = "${username}"; |
| 127 | mutableTaps = false; |
| 128 | taps = { |
| 129 | "homebrew/homebrew-core" = inputs.homebrew-core; |
| 130 | "homebrew/homebrew-cask" = inputs.homebrew-cask; |
| 131 | } // thirdPartyTaps; |
| 132 | # trust.taps = map (lib.replaceStrings [ "/homebrew-" ] [ "/" ]) |
| 133 | # (builtins.attrNames thirdPartyTaps); |
| 134 | }; |
| 135 | |
| 136 | # Install homebrew casks/apps |
| 137 | homebrew = { |
| 138 | enable = true; |
| 139 | |
| 140 | onActivation = { |
| 141 | autoUpdate = false; |
| 142 | upgrade = true; |
| 143 | cleanup = "zap"; |
| 144 | #extraFlags = [ "--force-cleanup" ]; |
| 145 | }; |
| 146 | |
| 147 | greedyCasks = true; # Force update for apps that "auto-update". I disable most built-in updaters. |
| 148 | # Disable above per-cask with {name: "xyz"; greedy = false; }; |
| 149 | |
| 150 | global.brewfile = true; |
| 151 | |
| 152 | taps = map (name: {inherit name; trusted = true; }) |
| 153 | (builtins.attrNames config.nix-homebrew.taps); |
| 154 | |
| 155 | brews = [ ]; |
| 156 | |
| 157 | casks = [ |
| 158 | "utm" |
| 159 | "ghostty" |
| 160 | "zen" |
| 161 | "ungoogled-chromium" |
| 162 | "tailscale-app" |
| 163 | "netbird-ui" |
| 164 | "ubersicht" |
| 165 | "hammerspoon" |
| 166 | "gimp" |
| 167 | "kdenlive" |
| 168 | "rustdesk" |
| 169 | "vorssaint" |
| 170 | "obs" |
| 171 | ]; |
| 172 | }; |
| 173 | |
| 174 | # Keyboard shortcuts using skhd |
| 175 | services.skhd = { |
| 176 | enable = true; |
| 177 | skhdConfig = '' |
| 178 | alt - d : osascript -e 'tell application "System Events" to key code 49 using {command down}' |
| 179 | alt - return : osascript -e 'tell application "Ghostty"' -e 'new window' -e 'activate' -e 'end tell' |
| 180 | ''; |
| 181 | }; |
| 182 | |
| 183 | # System configuration |
| 184 | time.timeZone = "America/New_York"; |
| 185 | |
| 186 | power.sleep = { |
| 187 | display = 10; |
| 188 | computer = 30; |
| 189 | }; |
| 190 | |
| 191 | system.defaults = { |
| 192 | NSGlobalDomain = { |
| 193 | # 24 hour time |
| 194 | AppleICUForce24HourTime = true; |
| 195 | |
| 196 | # Dark Mode |
| 197 | AppleInterfaceStyle = "Dark"; |
| 198 | |
| 199 | # Key repeat rate |
| 200 | KeyRepeat = 2; |
| 201 | InitialKeyRepeat = 35; |
| 202 | |
| 203 | # Swap F1-12 to be default |
| 204 | "com.apple.keyboard.fnState" = true; |
| 205 | |
| 206 | # Disable Keyboard bullcrap |
| 207 | NSAutomaticCapitalizationEnabled = false; |
| 208 | NSAutomaticDashSubstitutionEnabled = false; |
| 209 | NSAutomaticPeriodSubstitutionEnabled = false; |
| 210 | NSAutomaticQuoteSubstitutionEnabled = false; |
| 211 | NSAutomaticSpellingCorrectionEnabled = false; |
| 212 | ApplePressAndHoldEnabled = false; |
| 213 | }; |
| 214 | |
| 215 | # screensaver/power settings |
| 216 | screensaver = { |
| 217 | askForPassword = true; |
| 218 | askForPasswordDelay = 0; |
| 219 | }; |
| 220 | |
| 221 | # Control center stuff |
| 222 | controlcenter = { |
| 223 | BatteryShowPercentage = true; |
| 224 | Bluetooth = true; |
| 225 | }; |
| 226 | |
| 227 | # Clock settings |
| 228 | menuExtraClock = { |
| 229 | Show24Hour = true; |
| 230 | ShowDate = 1; # Always |
| 231 | ShowDayOfWeek = true; |
| 232 | ShowSeconds = true; |
| 233 | }; |
| 234 | |
| 235 | # Screen capture settings |
| 236 | screencapture = { |
| 237 | target = "clipboard"; |
| 238 | type = "png"; |
| 239 | }; |
| 240 | |
| 241 | # finder good settings |
| 242 | finder = { |
| 243 | AppleShowAllExtensions = true; |
| 244 | AppleShowAllFiles = true; |
| 245 | ShowPathbar = true; |
| 246 | FXEnableExtensionChangeWarning = false; |
| 247 | _FXShowPosixPathInTitle = true; |
| 248 | NewWindowTarget = "Home"; |
| 249 | ShowExternalHardDrivesOnDesktop = false; |
| 250 | ShowHardDrivesOnDesktop = false; |
| 251 | ShowMountedServersOnDesktop = false; |
| 252 | ShowRemovableMediaOnDesktop = false; |
| 253 | ShowStatusBar = true; |
| 254 | }; |
| 255 | |
| 256 | spaces = { |
| 257 | "spans-displays" = false; # independent spaces per display |
| 258 | }; |
| 259 | |
| 260 | # Login Window Settings |
| 261 | loginwindow = { |
| 262 | GuestEnabled = false; |
| 263 | DisableConsoleAccess = true; |
| 264 | }; |
| 265 | |
| 266 | # dock settings |
| 267 | dock = { |
| 268 | magnification = true; |
| 269 | largesize = 96; |
| 270 | tilesize = 32; |
| 271 | minimize-to-application = false; |
| 272 | orientation = "bottom"; |
| 273 | autohide = true; |
| 274 | mru-spaces = false; # Disable auto-rearrange spaces |
| 275 | persistent-apps = [ |
| 276 | { app = "/Applications/Zen.app"; } |
| 277 | #{ app = "/System/Applications/Launchpad.app"; } |
| 278 | { app = "/System/Applications/Messages.app"; } |
| 279 | { app = "/System/Applications/Facetime.app"; } |
| 280 | { app = "/System/Applications/Calendar.app"; } |
| 281 | { app = "/System/Applications/App Store.app"; } |
| 282 | { app = "/System/Applications/System Settings.app"; } |
| 283 | { app = "/Applications/Ghostty.app"; } |
| 284 | { app = "/Applications/UTM.app"; } |
| 285 | ]; |
| 286 | persistent-others = [ |
| 287 | { folder = { path = "/Users/${username}/Downloads"; showas = "grid"; arrangement = "date-created"; }; } |
| 288 | { folder = { path = "/Users/${username}/Applications"; showas = "grid"; arrangement = "name"; }; } |
| 289 | ]; |
| 290 | show-recents = false; |
| 291 | }; |
| 292 | |
| 293 | # Custom preferences |
| 294 | CustomUserPreferences = { |
| 295 | NSGlobalDomain = { |
| 296 | # Always show menu bar |
| 297 | AppleMenuBarVisibleInFullscreen = true; |
| 298 | |
| 299 | # Hide the menubar by default |
| 300 | "_HIHideMenuBar" = true; |
| 301 | |
| 302 | # Option + L lock |
| 303 | NSUserKeyEquivalents = { |
| 304 | "Lock Screen" = "~l"; |
| 305 | }; |
| 306 | }; |
| 307 | |
| 308 | "com.apple.desktopservices" = { |
| 309 | DSDontWriteNetworkStores = true; |
| 310 | DSDontWriteUSBStores = true; |
| 311 | }; |
| 312 | |
| 313 | "com.apple.WindowManager" = { |
| 314 | EnableStandardClickToShowDesktop = false; |
| 315 | StandardHideDesktopIcons = false; |
| 316 | }; |
| 317 | |
| 318 | "com.apple.screensaver" = { |
| 319 | askForPassword = true; |
| 320 | askForPasswordDelay = 2; |
| 321 | }; |
| 322 | |
| 323 | "com.apple.AdLib" = { |
| 324 | allowApplePersonalizedAdvertising = false; |
| 325 | }; |
| 326 | |
| 327 | "com.apple.Accessibility" = { |
| 328 | ReduceMotionEnabled = 1; |
| 329 | }; |
| 330 | }; |
| 331 | universalaccess.reduceMotion = false; |
| 332 | }; |
| 333 | |
| 334 | # Post-Activation scripts |
| 335 | system.activationScripts.postActivation.text = '' |
| 336 | echo "Configuring NTP servers..." |
| 337 | systemsetup -setnetworktimeserver pool.ntp.org > /dev/null 2>&1 || true |
| 338 | systemsetup -setusingnetworktime on > /dev/null 2>&1 || true |
| 339 | |
| 340 | ryancasum="$(${pkgs.openssl}/bin/openssl x509 -in "${../../files/CACerts/RyanCA.crt}" -noout -fingerprint -sha1 | sed 's/.*=//; s/://g')" |
| 341 | if ! /usr/bin/security find-certificate -a -Z "/Library/Keychains/System.keychain" | tr -d ':' | grep -iq "$ryancasum"; then |
| 342 | echo "Installing RyanCA Certificate..." |
| 343 | /usr/bin/security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ${../../files/CACerts/RyanCA.crt} |
| 344 | fi |
| 345 | |
| 346 | echo "Reloading Preferences DB..." |
| 347 | sudo -iu ${username} /System/Library/PrivateFrameworks/SystemAdministration.framework/Resources/activateSettings -u |
| 348 | |
| 349 | echo "Setting default browser" |
| 350 | ${pkgs.defaultbrowser}/bin/defaultbrowser ${defaultBrowser} |
| 351 | |
| 352 | echo "Adding Keyboard brightness controls to Control Center..." |
| 353 | sudo -iu ${username} defaults -currentHost write com.apple.controlcenter KeyboardBrightness -int 25 |
| 354 | |
| 355 | # this is fragile so it goes at the bottom |
| 356 | echo "Reloading skhd..." |
| 357 | sudo -iu ${username} ${pkgs.skhd}/bin/skhd -r || echo "Failed to reload skhd; continuing anyway..." |
| 358 | |
| 359 | # 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 |
| 360 | MARK="/opt/.nix-complete" |
| 361 | if [ ! -f "$MARK" ]; then |
| 362 | echo "o0o0o0o0o0o MacOS Initial Deploy Notes o0o0o0o0o0o" |
| 363 | echo "--------------------------------------------------" |
| 364 | echo "The following actions must be taken since they are not configurable by Nix. This must be done only ONCE." |
| 365 | echo "" |
| 366 | echo "1. Create 9 spaces." |
| 367 | echo "2. Set keyboard autofill settings" |
| 368 | echo "--------------------------------------------------" |
| 369 | fi |
| 370 | touch "$MARK" |
| 371 | ''; |
| 372 | |
| 373 | } |