-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathdarwin-unshittify.mod.nix
More file actions
115 lines (99 loc) · 3.05 KB
/
Copy pathdarwin-unshittify.mod.nix
File metadata and controls
115 lines (99 loc) · 3.05 KB
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
{
flake.darwinModules.unshittify =
{
config,
lib,
pkgs,
...
}:
let
inherit (lib.meta) getExe;
inherit (lib.modules) mkAfter;
inherit (lib.shell) asShell;
shadowPath = "/Users/${config.system.primaryUser}/.local/share/shadow";
in
{
# SHADOW-XCODE
system.activationScripts.script.text = mkAfter ''
${config.system.activationScripts.shadow-xcode.text}
'';
system.activationScripts.shadow-xcode.text = asShell pkgs.nushell "shadow-xcode.nu" /* nu */ ''
use std null_device
print "shadowing xcode..."
let shadow_path = r##'${shadowPath}'##
let original_size = ls /usr/bin/SplitForks | get 0.size
let shadoweds = ls /usr/bin
| flatten
| where {
$in.size == $original_size and (try {
open $null_device | ^$in.name out+err>| str contains "xcode-select: note: No developer tools were found, requesting install."
} catch {
false
})
}
| get name
| each { path basename }
rm -rf $shadow_path
mkdir $shadow_path
for shadowed in $shadoweds {
ln --symbolic /usr/bin/false ($shadow_path | path join $shadowed)
}
'';
# LOGIN WINDOW
system.defaults.loginwindow = {
DisableConsoleAccess = true;
GuestEnabled = false;
};
# SCREENSAVER PASSWORD
system.defaults.CustomSystemPreferences."com.apple.screensaver" = {
askForPassword = 1;
askForPasswordDelay = 0;
};
# CLOUD SAVES
system.defaults.NSGlobalDomain.NSDocumentSaveNewDocumentsToCloud = false;
# QUARANTINE
system.defaults.LaunchServices.LSQuarantine = false;
# AUTO-UPDATE
system.defaults.SoftwareUpdate.AutomaticallyInstallMacOSUpdates = false;
# AD TRACKING
system.defaults.CustomSystemPreferences."com.apple.AdLib" = {
allowApplePersonalizedAdvertising = false;
allowIdentifierForAdvertising = false;
forceLimitAdTracking = true;
personalizedAdsMigrated = false;
};
};
flake.homeModules.shadow-xcode =
{
config,
lib,
osConfig,
...
}:
let
inherit (lib.strings) optionalString;
shadowPath = "${config.xdg.data.directory}/shadow";
in
{
assertions = [
{
assertion =
!osConfig.nixpkgs.hostPlatform.isDarwin || shadowPath == "${config.directory}/.local/share/shadow";
message = "shadow-xcode: XDG_DATA_HOME drifted from the hardcoded path in darwinModules.unshittify";
}
];
programs.nushell.extraConfig =
# For some reason mkIf does not work here.
optionalString osConfig.nixpkgs.hostPlatform.isDarwin
<| /* nu */ ''
do --env {
let usr_bin_index = $env.PATH
| enumerate
| where item == /usr/bin
| get 0.index;
$env.PATH = $env.PATH
| insert $usr_bin_index "${shadowPath}";
}
'';
};
}