blob: 2f125dd2e71ffc4b3b2270d1828075e97aa3fcb8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
|
{ pkgs, inputs, lib, ... }:
let
username = "ryan";
defaultBrowser = "zen";
thirdPartyTaps = import ./taps.nix;
pinnedNixpkgs = pkgs.writeText "flake-registry.json" (builtins.toJSON {
version = 2;
flakes = [
{
from = { type = "indirect"; id = "nixpkgs"; };
to = {
type = "path";
path = inputs.nixpkgs.outPath;
lastModified = inputs.nixpkgs.lastModified;
narHash = inputs.nixpkgs.narHash;
};
}
];
});
mkSpace = i: {
name = toString (117+i);
value = {
enabled = true;
value = {
type = "standard";
parameters = [ (48 + i) (builtins.elemAt [ 18 19 20 21 22 23 25 26 28 ] (i - 1)) 524288 ];
};
};
};
spaceHotkeys = builtins.listToAttrs (map mkSpace (lib.range 1 9));
manualHotkeys = {
"64" = {
enabled = true;
};
};
in {
# Modules
imports = [
inputs.nix-homebrew.darwinModules.nix-homebrew
../../modules/darwin/random-wallpaper.nix
];
# Define the system's user and home dir location
users.users."${username}" = {
name = "${username}";
home = "/Users/${username}";
};
system.primaryUser = "${username}";
# Install the wallpaper engine
local.randomWallpaper = {
enable = true;
directory = "${../../files/Wallpapers}";
};
# Configure yabai
services.yabai = {
enable = true;
enableScriptingAddition = false;
config = {
mouse_follows_focus = "on";
layout = "bsp";
window_placement = "second_child";
top_padding = "10";
bottom_padding = "10";
left_padding = "10";
right_padding = "10";
window_gap = "5";
mouse_modifier = "alt";
mouse_drop_action = "swap";
mouse_action1 = "move";
mouse_action2 = "resize";
focus_follows_mouse = "autofocus";
};
extraConfig = ''
yabai -m rule --add app='System Settings' manage=off
borders style=round active_color='gradient(top_left=0xee33ccff,bottom_right=0xee00ff99)' inactive_color=0xaa595959 width=6.0
'';
};
# Install the /etc/nix/flake-registry.json file we made above
environment.etc."nix/flake-registry.json".source = pinnedNixpkgs;
# Install RyanCA Root
security.pki.certificateFiles = [
../../files/CACerts/RyanCA.crt
];
# Need to disable native nix handling because of Determinate nix
determinateNix = {
enable = true;
customSettings = {
flake-registry = "/etc/nix/flake-registry.json";
};
};
# Determines the nix-darwin release compatibility
system.stateVersion = 6;
# System profile programs
programs = {
zsh.enable = true;
};
# Install homebrew itself
nix-homebrew = {
enable = true;
enableRosetta = true;
user = "${username}";
mutableTaps = false;
taps = thirdPartyTaps;
trust.taps = builtins.attrNames thirdPartyTaps;
};
# Install homebrew casks/apps
homebrew = {
enable = true;
onActivation = {
cleanup = "zap";
};
global.brewfile = true;
taps = builtins.attrNames thirdPartyTaps;
brews = [
"borders"
"mqttx-cli"
];
casks = [
"utm"
"ghostty"
"zen"
"ungoogled-chromium"
"tailscale-app"
"netbird-ui"
];
};
# Keyboard shortcuts using skhd
services.skhd = {
enable = true;
skhdConfig = ''
cmd - d : osascript -e 'tell application "System Events" to key code 49 using {command down}'
cmd - return : osascript -e 'tell application "Ghostty"' -e 'new window' -e 'activate' -e 'end tell'
cmd - up : ${pkgs.yabai}/bin/yabai -m window --focus north || ${pkgs.yabai}/bin/yabai -m display --focus north
shift + cmd - up : ${pkgs.yabai}/bin/yabai -m window --swap north || ${pkgs.yabai}/bin/yabai -m window --display north
cmd - down : ${pkgs.yabai}/bin/yabai -m window --focus south || ${pkgs.yabai}/bin/yabai -m display --focus south
shift + cmd - down : ${pkgs.yabai}/bin/yabai -m window --swap south || ${pkgs.yabai}/bin/yabai -m window --display south
cmd - right : ${pkgs.yabai}/bin/yabai -m window --focus east || ${pkgs.yabai}/bin/yabai -m display --focus east
shift + cmd - right : ${pkgs.yabai}/bin/yabai -m window --swap east || ${pkgs.yabai}/bin/yabai -m window --display east
cmd - left : ${pkgs.yabai}/bin/yabai -m window --focus west || ${pkgs.yabai}/bin/yabai -m display --focus west
shift + cmd - left: ${pkgs.yabai}/bin/yabai -m window --swap west || ${pkgs.yabai}/bin/yabai -m window --display west
shift + cmd - space: ${pkgs.yabai}/bin/yabai -m window --toggle float
shift + cmd - return: ${pkgs.yabai}/bin/yabai -m window --toggle sticky
cmd - f : ${pkgs.yabai}/bin/yabai -m window --toggle zoom-fullscreen
shift + cmd - f: ${pkgs.yabai}/bin/yabai -m window --toggle native-fullscreen
shift + cmd - 1 : ${pkgs.yabai}/bin/yabai -m window --space 1
shift + cmd - 2 : ${pkgs.yabai}/bin/yabai -m window --space 2
shift + cmd - 3 : ${pkgs.yabai}/bin/yabai -m window --space 3
shift + cmd - 4 : ${pkgs.yabai}/bin/yabai -m window --space 4
shift + cmd - 5 : ${pkgs.yabai}/bin/yabai -m window --space 5
shift + cmd - 6 : ${pkgs.yabai}/bin/yabai -m window --space 6
shift + cmd - 7 : ${pkgs.yabai}/bin/yabai -m window --space 7
shift + cmd - 8 : ${pkgs.yabai}/bin/yabai -m window --space 8
shift + cmd - 9 : ${pkgs.yabai}/bin/yabai -m window --space 9
'';
};
# System configuration
time.timeZone = "America/New_York";
power.sleep = {
display = 10;
computer = 30;
};
system.defaults = {
NSGlobalDomain = {
# 24 hour time
AppleICUForce24HourTime = true;
# Dark Mode
AppleInterfaceStyle = "Dark";
# Key repeat rate
KeyRepeat = 4;
InitialKeyRepeat = 30;
# Swap F1-12 to be default
"com.apple.keyboard.fnState" = true;
# Disable Keyboard bullcrap
NSAutomaticCapitalizationEnabled = false;
NSAutomaticDashSubstitutionEnabled = false;
NSAutomaticPeriodSubstitutionEnabled = false;
NSAutomaticQuoteSubstitutionEnabled = false;
NSAutomaticSpellingCorrectionEnabled = false;
ApplePressAndHoldEnabled = false;
};
# screensaver/power settings
screensaver = {
askForPassword = true;
askForPasswordDelay = 0;
};
# Control center stuff
controlcenter = {
BatteryShowPercentage = true;
Bluetooth = true;
};
# Clock settings
menuExtraClock = {
Show24Hour = true;
ShowDate = 1; # Always
ShowDayOfWeek = true;
ShowSeconds = true;
};
# Screen capture settings
screencapture = {
target = "clipboard";
type = "png";
};
# finder good settings
finder = {
AppleShowAllExtensions = true;
AppleShowAllFiles = true;
ShowPathbar = true;
FXEnableExtensionChangeWarning = false;
_FXShowPosixPathInTitle = true;
NewWindowTarget = "Home";
ShowExternalHardDrivesOnDesktop = false;
ShowHardDrivesOnDesktop = false;
ShowMountedServersOnDesktop = false;
ShowRemovableMediaOnDesktop = false;
ShowStatusBar = true;
};
spaces = {
"spans-displays" = false; # independent spaces per display
};
# Login Window Settings
loginwindow = {
GuestEnabled = false;
DisableConsoleAccess = true;
};
# dock settings
dock = {
magnification = true;
largesize = 96;
tilesize = 32;
minimize-to-application = false;
orientation = "bottom";
autohide = true;
mru-spaces = false; # Disable auto-rearrange spaces
persistent-apps = [
{ app = "/Applications/Zen.app"; }
#{ app = "/System/Applications/Launchpad.app"; }
{ app = "/System/Applications/Messages.app"; }
{ app = "/System/Applications/Facetime.app"; }
{ app = "/System/Applications/Calendar.app"; }
{ app = "/System/Applications/App Store.app"; }
{ app = "/System/Applications/System Settings.app"; }
{ app = "/Applications/UTM.app"; }
];
persistent-others = [
{ folder = { path = "/Users/${username}/Downloads"; showas = "grid"; arrangement = "date-created"; }; }
{ folder = { path = "/Users/${username}/Applications"; showas = "grid"; arrangement = "name"; }; }
];
show-recents = false;
};
# Custom preferences
CustomUserPreferences = {
NSGlobalDomain = {
# Always show menu bar
AppleMenuBarVisibleInFullscreen = true;
# Option + L lock
NSUserKeyEquivalents = {
"Lock Screen" = "~l";
};
};
"com.apple.Accessibility" = {
ReduceMotionEnabled = 1;
};
"com.apple.symbolichotkeys" = {
AppleSymbolicHotKeys = manualHotkeys // spaceHotkeys;
};
};
universalaccess.reduceMotion = true;
};
# Post-Activation scripts
system.activationScripts.postActivation.text = ''
echo "Configuring NTP servers..."
systemsetup -setnetworktimeserver pool.ntp.org > /dev/null 2>&1 || true
systemsetup -setusingnetworktime on > /dev/null 2>&1 || true
ryancasum="$(${pkgs.openssl}/bin/openssl x509 -in "${../../files/CACerts/RyanCA.crt}" -noout -fingerprint -sha1 | sed 's/.*=//; s/://g')"
if ! /usr/bin/security find-certificate -a -Z "/Library/Keychains/System.keychain" | tr -d ':' | grep -iq "$ryancasum"; then
echo "Installing RyanCA Certificate..."
/usr/bin/security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ${../../files/CACerts/RyanCA.crt}
fi
echo "Reloading Preferences DB..."
sudo -iu ${username} /System/Library/PrivateFrameworks/SystemAdministration.framework/Resources/activateSettings -u
echo "Setting default browser"
${pkgs.defaultbrowser}/bin/defaultbrowser ${defaultBrowser}
echo "Adding Keyboard brightness controls to Control Center..."
sudo -iu ${username} defaults -currentHost write com.apple.controlcenter KeyboardBrightness -int 25
# this is fragile so it goes at the bottom
echo "Reloading skhd..."
sudo -iu ${username} ${pkgs.skhd}/bin/skhd -r
# 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
MARK="/opt/.nix-complete"
if [ ! -f "$MARK" ]; then
echo "o0o0o0o0o0o MacOS Initial Deploy Notes o0o0o0o0o0o"
echo "--------------------------------------------------"
echo "The following actions must be taken since they are not configurable by Nix. This must be done only ONCE."
echo ""
echo "1. Create 9 spaces."
echo "2. Set a wallpaper as visible in all spaces."
echo "--------------------------------------------------"
fi
touch "$MARK"
'';
}
|