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