hosts/RyanMac/configuration.nix

8f0d8e6dfe4632c461658a7db8f0eeb5261d62df · 6.1 KB · 242 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 brews = [
78 ];
79
80 casks = [
81 "glide"
82 "utm"
83 "ghostty"
84 "zen"
85 "tailscale-app"
86 "netbird-ui"
87 ];
88 };
89
90 # Keyboard shortcuts using skhd
91 services.skhd = {
92 enable = true;
93 skhdConfig = ''
94 alt - d : osascript -e 'tell application "System Events" to key code 49 using {command down}'
95 alt - return : open -na /Applications/Ghostty.app
96 '';
97 };
98
99 # System configuration
100 time.timeZone = "America/New_York";
101
102 power.sleep = {
103 display = 10;
104 computer = 30;
105 };
106
107 system.defaults = {
108 NSGlobalDomain = {
109 # 24 hour time
110 AppleICUForce24HourTime = true;
111
112 # Dark Mode
113 AppleInterfaceStyle = "Dark";
114
115 # Key repeat rate
116 KeyRepeat = 4;
117 InitialKeyRepeat = 30;
118
119 # Swap F1-12 to be default
120 "com.apple.keyboard.fnState" = true;
121
122 # Disable Keyboard bullcrap
123 NSAutomaticCapitalizationEnabled = false;
124 NSAutomaticDashSubstitutionEnabled = false;
125 NSAutomaticPeriodSubstitutionEnabled = false;
126 NSAutomaticQuoteSubstitutionEnabled = false;
127 NSAutomaticSpellingCorrectionEnabled = false;
128 ApplePressAndHoldEnabled = false;
129 };
130
131 # screensaver/power settings
132 screensaver = {
133 askForPassword = true;
134 askForPasswordDelay = 0;
135 };
136
137 # Control center stuff
138 controlcenter = {
139 BatteryShowPercentage = true;
140 };
141
142 # Clock settings
143 menuExtraClock = {
144 Show24Hour = true;
145 ShowDate = 1; # Always
146 ShowDayOfWeek = true;
147 ShowSeconds = true;
148 };
149
150 # Screen capture settings
151 screencapture = {
152 target = "clipboard";
153 type = "png";
154 };
155
156 # finder good settings
157 finder = {
158 AppleShowAllExtensions = true;
159 AppleShowAllFiles = true;
160 ShowPathbar = true;
161 FXEnableExtensionChangeWarning = false;
162 _FXShowPosixPathInTitle = true;
163 NewWindowTarget = "Home";
164 ShowExternalHardDrivesOnDesktop = false;
165 ShowHardDrivesOnDesktop = false;
166 ShowMountedServersOnDesktop = false;
167 ShowRemovableMediaOnDesktop = false;
168 ShowStatusBar = true;
169 };
170
171 # Login Window Settings
172 loginwindow = {
173 GuestEnabled = false;
174 DisableConsoleAccess = true;
175 };
176
177 # dock settings
178 dock = {
179 magnification = true;
180 largesize = 96;
181 tilesize = 32;
182 minimize-to-application = false;
183 orientation = "bottom";
184 autohide = true;
185 persistent-apps = [
186 { app = "/Applications/Zen.app"; }
187 #{ app = "/System/Applications/Launchpad.app"; }
188 { app = "/System/Applications/Messages.app"; }
189 { app = "/System/Applications/Facetime.app"; }
190 { app = "/System/Applications/Calendar.app"; }
191 { app = "/System/Applications/App Store.app"; }
192 { app = "/System/Applications/System Settings.app"; }
193 { app = "/Applications/UTM.app"; }
194 ];
195 persistent-others = [
196 { folder = { path = "/Users/${username}/Downloads"; showas = "grid"; arrangement = "date-created"; }; }
197 { folder = { path = "/Users/${username}/Applications"; showas = "grid"; arrangement = "name"; }; }
198 ];
199 show-recents = false;
200 };
201
202 # Custom preferences
203 CustomUserPreferences = {
204 NSGlobalDomain = {
205 # Always show menu bar
206 AppleMenuBarVisibleInFullscreen = true;
207 };
208
209 "com.apple.symbolichotkeys" = {
210 AppleSymbolicHotKeys = {
211 "64" = {
212 enabled = true; # skhd needs this for its shortcut
213 };
214 };
215 };
216 };
217 };
218
219 # Post-Activation scripts
220 system.activationScripts.postActivation.text = ''
221 echo "Configuring NTP servers..."
222 systemsetup -setnetworktimeserver pool.ntp.org > /dev/null 2>&1 || true
223 systemsetup -setusingnetworktime on > /dev/null 2>&1 || true
224
225 ryancasum="$(${pkgs.openssl}/bin/openssl x509 -in "${../../files/CACerts/RyanCA.crt}" -noout -fingerprint -sha1 | sed 's/.*=//; s/://g')"
226 if ! /usr/bin/security find-certificate -a -Z "/Library/Keychains/System.keychain" | tr -d ':' | grep -iq "$ryancasum"; then
227 echo "Installing RyanCA Certificate..."
228 /usr/bin/security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ${../../files/CACerts/RyanCA.crt}
229 fi
230
231 echo "Reloading Preferences DB..."
232 /System/Library/PrivateFrameworks/SystemAdministration.framework/Resources/activateSettings -u
233
234 echo "Setting default browser"
235 ${pkgs.defaultbrowser}/bin/defaultbrowser ${defaultBrowser}
236
237 # this is fragile so it goes at the bottom
238 echo "Reloading skhd..."
239 sudo -iu ${username} ${pkgs.skhd}/bin/skhd -r
240 '';
241
242 }