hosts/RyanMac/configuration.nix

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