-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path_darwin.nix
More file actions
87 lines (76 loc) · 1.91 KB
/
_darwin.nix
File metadata and controls
87 lines (76 loc) · 1.91 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
{
config,
pkgs,
lib,
...
}:
let
cfg = config.my.deviceManager;
identifier = "com.nix.managed.profile";
nixProfile = lib.generators.toPlist { escape = true; } {
PayloadDisplayName = "Nix Profile";
PayloadUUID = identifier;
PayloadIdentifier = identifier;
PayloadOrganization = config.my.user.name;
PayloadType = "Configuration";
PayloadScope = "System"; # Default is User
PayloadVersion = 1;
PayloadContent = map (
profile:
profile.payload
// {
PayloadDisplayName = profile.name;
PayloadUUID = profile.domain;
PayloadIdentifier = profile.domain;
PayloadType = profile.domain;
PayloadVersion = 1;
}
) cfg.profiles;
};
warn = "${lib.getExe pkgs.gum} style --foreground 3";
# https://archive.is/948rD
openPreferences = pane: ''
/usr/bin/open "x-apple.systempreferences:${pane}"
'';
in
{
options.my.deviceManager = with lib; {
profiles = mkOption {
type = types.listOf (
types.submodule {
options = {
name = mkOption {
type = types.str;
example = "Google Chrome";
};
domain = mkOption {
type = types.str;
example = "com.google.Chrome";
};
payload = mkOption {
type = types.attrsOf types.anything;
};
};
}
);
default = [
{
name = "placeholder";
domain = "com.placeholder";
payload = { };
}
];
};
};
config = {
home.file."nix.mobileconfig" = {
text = nixProfile;
force = true;
onChange = ''
${warn} "Device Manager: ~/nix.mobileconfig has chanaged. Install the \
new profile via system preferences for changes to take affect."
${openPreferences "com.apple.preferences.configurationprofiles"}
'';
};
};
}