fork/home-manager

git clone https://git.julia.blue/fork/home-manager

Robert HelgessonMerge PR #421575790441

master
5.8 KiB202 linesraw
1{ config, lib, ... }:
2
3with lib;
4
5let
6  mkNullableOption = args:
7    lib.mkOption (args // {
8      type = types.nullOr args.type;
9      default = null;
10    });
11
12  mkNullableEnableOption = name:
13    lib.mkOption {
14      type = with types; nullOr bool;
15      default = null;
16      example = true;
17      description = "Whether to enable ${name}.";
18    };
19
20  safari = config."com.apple.Safari";
21in {
22  freeformType = with types; attrsOf (attrsOf anything);
23
24  options = {
25    NSGlobalDomain = {
26      AppleLanguages = mkNullableOption {
27        type = with types; listOf str;
28        example = [ "en" ];
29        description = "Sets the language to use in the preferred order.";
30      };
31
32      AppleLocale = mkNullableOption {
33        type = types.str;
34        example = "en_US";
35        description = "Configures the user locale.";
36      };
37
38      AppleMeasurementUnits = mkNullableOption {
39        type = types.enum [ "Centimeters" "Inches" ];
40        example = "Centimeters";
41        description = "Sets the measurement unit.";
42      };
43
44      AppleTemperatureUnit = mkNullableOption {
45        type = types.enum [ "Celsius" "Fahrenheit" ];
46        example = "Celsius";
47        description = "Sets the temperature unit.";
48      };
49
50      AppleMetricUnits = mkNullableEnableOption "the metric system";
51
52      NSAutomaticCapitalizationEnabled =
53        mkNullableEnableOption "automatic capitalization";
54
55      NSAutomaticDashSubstitutionEnabled =
56        mkNullableEnableOption "smart dashes";
57
58      NSAutomaticPeriodSubstitutionEnabled =
59        mkNullableEnableOption "period with double space";
60
61      NSAutomaticQuoteSubstitutionEnabled =
62        mkNullableEnableOption "smart quotes";
63
64      NSAutomaticSpellingCorrectionEnabled =
65        mkNullableEnableOption "spelling correction";
66    };
67
68    "com.apple.desktopservices" = {
69      DSDontWriteNetworkStores = mkNullableOption {
70        type = types.bool;
71        example = false;
72        description = ''
73          Disable use of {file}`.DS_Store` files on network shares.
74          See [the
75          official article](https://support.apple.com/en-us/HT208209) for more info.
76        '';
77      };
78      DSDontWriteUSBStores = mkNullableOption {
79        type = types.bool;
80        example = false;
81        description = ''
82          Disable use of {file}`.DS_Store` files on thumb drives.
83        '';
84      };
85    };
86
87    "com.apple.dock" = {
88      tilesize = mkNullableOption {
89        type = types.int;
90        example = 64;
91        description = "Sets the size of the dock.";
92      };
93      size-immutable = mkNullableEnableOption "locking of the dock size";
94      expose-group-apps = mkNullableEnableOption
95        "grouping of windows by application in Mission Control";
96    };
97
98    "com.apple.menuextra.battery".ShowPercent = mkNullableOption {
99      type = types.enum [ "YES" "NO" ];
100      example = "NO";
101      description = ''
102        This option no longer works on macOS 11 and later. Instead, use
103        {option}`targets.darwin.currentHostDefaults.\"com.apple.controlcenter\".BatteryShowPercentage`.
104
105        Whether to show battery percentage in the menu bar.
106      '';
107    };
108
109    "com.apple.Safari" = {
110      AutoOpenSafeDownloads =
111        mkNullableEnableOption "opening of downloaded files";
112      AutoFillPasswords =
113        mkNullableEnableOption "autofill of usernames and passwords";
114      AutoFillCreditCardData =
115        mkNullableEnableOption "autofill of credit card numbers";
116      IncludeDevelopMenu =
117        mkNullableEnableOption ''"Develop" menu in the menu bar'';
118      ShowOverlayStatusBar = mkNullableEnableOption "status bar";
119
120      WebKitDeveloperExtrasEnabledPreferenceKey = mkNullableOption {
121        type = types.bool;
122        description = ''
123          Configures the web inspector.
124
125          ::: {.warning}
126          Instead of setting this option directly, set
127          {option}`IncludeDevelopMenu` instead.
128          :::
129        '';
130      };
131      "WebKitPreferences.developerExtrasEnabled" = mkNullableOption {
132        type = types.bool;
133        description = ''
134          Configures the web inspector.
135
136          ::: {.warning}
137          Instead of setting this option directly, set
138          {option}`IncludeDevelopMenu` instead.
139          :::
140        '';
141      };
142    };
143
144    "com.apple.Safari.SandboxBroker" = {
145      ShowDevelopMenu = mkNullableOption {
146        type = types.bool;
147        description = ''
148          Show the "Develop" menu in Safari's menubar.
149
150          ::: {.warning}
151          Instead of setting this option directly, set
152          {option}`"com.apple.Safari".IncludeDevelopMenu` instead.
153          :::
154        '';
155      };
156    };
157
158    "com.googlecode.iterm2" = {
159      AddNewTabAtEndOfTabs = mkNullableEnableOption
160        "placement of new tabs at the end of the tab bar";
161
162      AlternateMouseScroll = mkNullableEnableOption
163        "arrow keys when scrolling in alternate screen mode";
164
165      CopySelection =
166        mkNullableEnableOption "copy to clipboard upon selecting text";
167
168      OpenTmuxWindowsIn = mkNullableOption {
169        type = types.int;
170        example = 2;
171        description = ''
172          Configures how to restore tmux windows when attaching to a session.
173
174          **Possible Values**
175
176          `0`
177          : Native windows
178
179          `1`
180          : Native tabs in a new window
181
182          `2`
183          : Tabs in the attaching window
184        '';
185      };
186
187      ExperimentalKeyHandling = mkNullableEnableOption
188        "experimental key handling for AquaSKK compatibility";
189    };
190  };
191
192  config = {
193    "com.apple.Safari" = mkIf (safari.IncludeDevelopMenu != null) {
194      WebKitDeveloperExtrasEnabledPreferenceKey = safari.IncludeDevelopMenu;
195      "WebKitPreferences.developerExtrasEnabled" = safari.IncludeDevelopMenu;
196    };
197    "com.apple.Safari.SandboxBroker" =
198      mkIf (safari.IncludeDevelopMenu != null) {
199        ShowDevelopMenu = safari.IncludeDevelopMenu;
200      };
201  };
202}