hosts/RyanMac/configuration.nix

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