hosts/RyanMac/configuration.nix
fa4e176191c8bebe7f1e45b4b4512c0bd10244e1
· 6.1 KB · 238 lines
raw
| 1 | { pkgs, inputs, ... }: |
| 2 | let |
| 3 | username = "ryan"; |
| 4 | |
| 5 | defaultBrowser = "zen"; |
| 6 | |
| 7 | pinnedNixpkgs = pkgs.writeText "flake-registry.json" (builtins.toJSON { |
| 8 | version = 2; |
| 9 | flakes = [ |
| 10 | { |
| 11 | from = { type = "indirect"; id = "nixpkgs"; }; |
| 12 | to = { |
| 13 | type = "path"; |
| 14 | path = inputs.nixpkgs.outPath; |
| 15 | lastModified = inputs.nixpkgs.lastModified; |
| 16 | narHash = inputs.nixpkgs.narHash; |
| 17 | }; |
| 18 | } |
| 19 | ]; |
| 20 | }); |
| 21 | |
| 22 | in { |
| 23 | # Modules |
| 24 | imports = [ ../../modules/darwin/random-wallpaper.nix ]; |
| 25 | |
| 26 | # Define the system's user and home dir location |
| 27 | users.users."${username}" = { |
| 28 | name = "${username}"; |
| 29 | home = "/Users/${username}"; |
| 30 | }; |
| 31 | |
| 32 | system.primaryUser = "${username}"; |
| 33 | |
| 34 | # Install the wallpaper engine |
| 35 | local.randomWallpaper = { |
| 36 | enable = true; |
| 37 | directory = "${../../files/Wallpapers}"; |
| 38 | }; |
| 39 | |
| 40 | # Install the /etc/nix/flake-registry.json file we made above |
| 41 | environment.etc."nix/flake-registry.json".source = pinnedNixpkgs; |
| 42 | |
| 43 | # Install RyanCA Root |
| 44 | security.pki.certificateFiles = [ |
| 45 | ../../files/CACerts/RyanCA.crt |
| 46 | ]; |
| 47 | |
| 48 | # Need to disable native nix handling because of Determinate nix |
| 49 | determinateNix = { |
| 50 | enable = true; |
| 51 | customSettings = { |
| 52 | flake-registry = "/etc/nix/flake-registry.json"; |
| 53 | }; |
| 54 | }; |
| 55 | |
| 56 | # Determines the nix-darwin release compatibility |
| 57 | system.stateVersion = 6; |
| 58 | |
| 59 | # System profile programs |
| 60 | programs = { |
| 61 | zsh.enable = true; |
| 62 | }; |
| 63 | |
| 64 | # Install homebrew casks/apps |
| 65 | homebrew = { |
| 66 | enable = true; |
| 67 | |
| 68 | onActivation = { |
| 69 | cleanup = "zap"; |
| 70 | extraFlags = [ "--force-cleanup" ]; |
| 71 | }; |
| 72 | |
| 73 | taps = [ |
| 74 | "netbirdio/tap" |
| 75 | ]; |
| 76 | |
| 77 | casks = [ |
| 78 | "utm" |
| 79 | "ghostty" |
| 80 | "zen" |
| 81 | "tailscale-app" |
| 82 | "netbird-ui" |
| 83 | ]; |
| 84 | }; |
| 85 | |
| 86 | # Keyboard shortcuts using skhd |
| 87 | services.skhd = { |
| 88 | enable = true; |
| 89 | skhdConfig = '' |
| 90 | alt - d : osascript -e 'tell application "System Events" to key code 49 using {command down}' |
| 91 | alt - return : open -na /Applications/Ghostty.app |
| 92 | ''; |
| 93 | }; |
| 94 | |
| 95 | # System configuration |
| 96 | time.timeZone = "America/New_York"; |
| 97 | |
| 98 | power.sleep = { |
| 99 | display = 10; |
| 100 | computer = 30; |
| 101 | }; |
| 102 | |
| 103 | system.defaults = { |
| 104 | NSGlobalDomain = { |
| 105 | # 24 hour time |
| 106 | AppleICUForce24HourTime = true; |
| 107 | |
| 108 | # Dark Mode |
| 109 | AppleInterfaceStyle = "Dark"; |
| 110 | |
| 111 | # Key repeat rate |
| 112 | KeyRepeat = 4; |
| 113 | InitialKeyRepeat = 30; |
| 114 | |
| 115 | # Swap F1-12 to be default |
| 116 | "com.apple.keyboard.fnState" = true; |
| 117 | |
| 118 | # Disable Keyboard bullcrap |
| 119 | NSAutomaticCapitalizationEnabled = false; |
| 120 | NSAutomaticDashSubstitutionEnabled = false; |
| 121 | NSAutomaticPeriodSubstitutionEnabled = false; |
| 122 | NSAutomaticQuoteSubstitutionEnabled = false; |
| 123 | NSAutomaticSpellingCorrectionEnabled = false; |
| 124 | ApplePressAndHoldEnabled = false; |
| 125 | }; |
| 126 | |
| 127 | # screensaver/power settings |
| 128 | screensaver = { |
| 129 | askForPassword = true; |
| 130 | askForPasswordDelay = 0; |
| 131 | }; |
| 132 | |
| 133 | # Control center stuff |
| 134 | controlcenter = { |
| 135 | BatteryShowPercentage = true; |
| 136 | }; |
| 137 | |
| 138 | # Clock settings |
| 139 | menuExtraClock = { |
| 140 | Show24Hour = true; |
| 141 | ShowDate = 1; # Always |
| 142 | ShowDayOfWeek = true; |
| 143 | ShowSeconds = true; |
| 144 | }; |
| 145 | |
| 146 | # Screen capture settings |
| 147 | screencapture = { |
| 148 | target = "clipboard"; |
| 149 | type = "png"; |
| 150 | }; |
| 151 | |
| 152 | # finder good settings |
| 153 | finder = { |
| 154 | AppleShowAllExtensions = true; |
| 155 | AppleShowAllFiles = true; |
| 156 | ShowPathbar = true; |
| 157 | FXEnableExtensionChangeWarning = false; |
| 158 | _FXShowPosixPathInTitle = true; |
| 159 | NewWindowTarget = "Home"; |
| 160 | ShowExternalHardDrivesOnDesktop = false; |
| 161 | ShowHardDrivesOnDesktop = false; |
| 162 | ShowMountedServersOnDesktop = false; |
| 163 | ShowRemovableMediaOnDesktop = false; |
| 164 | ShowStatusBar = true; |
| 165 | }; |
| 166 | |
| 167 | # Login Window Settings |
| 168 | loginwindow = { |
| 169 | GuestEnabled = false; |
| 170 | DisableConsoleAccess = true; |
| 171 | }; |
| 172 | |
| 173 | # dock settings |
| 174 | dock = { |
| 175 | magnification = true; |
| 176 | largesize = 96; |
| 177 | tilesize = 32; |
| 178 | minimize-to-application = false; |
| 179 | orientation = "bottom"; |
| 180 | autohide = true; |
| 181 | persistent-apps = [ |
| 182 | { app = "/Applications/Zen.app"; } |
| 183 | #{ app = "/System/Applications/Launchpad.app"; } |
| 184 | { app = "/System/Applications/Messages.app"; } |
| 185 | { app = "/System/Applications/Facetime.app"; } |
| 186 | { app = "/System/Applications/Calendar.app"; } |
| 187 | { app = "/System/Applications/App Store.app"; } |
| 188 | { app = "/System/Applications/System Settings.app"; } |
| 189 | { app = "/Applications/UTM.app"; } |
| 190 | ]; |
| 191 | persistent-others = [ |
| 192 | { folder = { path = "/Users/${username}/Downloads"; showas = "grid"; arrangement = "date-created"; }; } |
| 193 | { folder = { path = "/Users/${username}/Applications"; showas = "grid"; arrangement = "name"; }; } |
| 194 | ]; |
| 195 | show-recents = false; |
| 196 | }; |
| 197 | |
| 198 | # Custom preferences |
| 199 | CustomUserPreferences = { |
| 200 | NSGlobalDomain = { |
| 201 | # Always show menu bar |
| 202 | AppleMenuBarVisibleInFullscreen = true; |
| 203 | }; |
| 204 | |
| 205 | "com.apple.symbolichotkeys" = { |
| 206 | AppleSymbolicHotKeys = { |
| 207 | "64" = { |
| 208 | enabled = true; # skhd needs this for its shortcut |
| 209 | }; |
| 210 | }; |
| 211 | }; |
| 212 | }; |
| 213 | }; |
| 214 | |
| 215 | # Post-Activation scripts |
| 216 | system.activationScripts.postActivation.text = '' |
| 217 | echo "Configuring NTP servers..." |
| 218 | systemsetup -setnetworktimeserver pool.ntp.org > /dev/null 2>&1 || true |
| 219 | systemsetup -setusingnetworktime on > /dev/null 2>&1 || true |
| 220 | |
| 221 | ryancasum="$(${pkgs.openssl}/bin/openssl x509 -in "${../../files/CACerts/RyanCA.crt}" -noout -fingerprint -sha1 | sed 's/.*=//; s/://g')" |
| 222 | if ! /usr/bin/security find-certificate -a -Z "/Library/Keychains/System.keychain" | tr -d ':' | grep -iq "$ryancasum"; then |
| 223 | echo "Installing RyanCA Certificate..." |
| 224 | /usr/bin/security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ${../../files/CACerts/RyanCA.crt} |
| 225 | fi |
| 226 | |
| 227 | echo "Reloading Preferences DB..." |
| 228 | /System/Library/PrivateFrameworks/SystemAdministration.framework/Resources/activateSettings -u |
| 229 | |
| 230 | echo "Setting default browser" |
| 231 | ${pkgs.defaultbrowser}/bin/defaultbrowser ${defaultBrowser} |
| 232 | |
| 233 | # this is fragile so it goes at the bottom |
| 234 | echo "Reloading skhd..." |
| 235 | sudo -iu ${username} ${pkgs.skhd}/bin/skhd -r |
| 236 | ''; |
| 237 | |
| 238 | } |