diff options
| author | Pavel Shirshov <pshirshov@eml.cc> | 2022-10-24 13:12:54 +0100 |
|---|---|---|
| committer | Pavel Shirshov <pshirshov@eml.cc> | 2022-10-24 13:12:54 +0100 |
| commit | c946ee42fa30400c89b7ba3d5445e098266238a8 (patch) | |
| tree | 200e6d4c11e82fda0dc44e742734eeff7f6d22d0 /modules | |
| parent | 8be7f197120739b3ec15f994bdc48116726c6159 (diff) | |
#517: custom preferences for 'defaults' can be specified
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/module-list.nix | 1 | ||||
| -rw-r--r-- | modules/system/defaults-write.nix | 6 | ||||
| -rw-r--r-- | modules/system/defaults/CustomPreferences.nix | 38 |
3 files changed, 45 insertions, 0 deletions
diff --git a/modules/module-list.nix b/modules/module-list.nix index 23a4254..def1c88 100644 --- a/modules/module-list.nix +++ b/modules/module-list.nix @@ -14,6 +14,7 @@ ./system/defaults/LaunchServices.nix ./system/defaults/NSGlobalDomain.nix ./system/defaults/GlobalPreferences.nix + ./system/defaults/CustomPreferences.nix ./system/defaults/dock.nix ./system/defaults/finder.nix ./system/defaults/screencapture.nix diff --git a/modules/system/defaults-write.nix b/modules/system/defaults-write.nix index 8a6cb6e..8d8f57e 100644 --- a/modules/system/defaults-write.nix +++ b/modules/system/defaults-write.nix @@ -39,6 +39,8 @@ let trackpadBluetooth = defaultsToList "com.apple.driver.AppleBluetoothMultitouch.trackpad" cfg.trackpad; universalaccess = defaultsToList "com.apple.universalaccess" cfg.universalaccess; ActivityMonitor = defaultsToList "com.apple.ActivityMonitor" cfg.ActivityMonitor; + CustomUserPreferences = flatten (mapAttrsToList (name: value: defaultsToList name value) cfg.CustomUserPreferences); + CustomSystemPreferences = flatten (mapAttrsToList (name: value: defaultsToList name value) cfg.CustomSystemPreferences); mkIfAttrs = list: mkIf (any (attrs: attrs != { }) list); in @@ -60,6 +62,7 @@ in loginwindow smb SoftwareUpdate + CustomSystemPreferences ] '' # Set defaults @@ -68,6 +71,7 @@ in ${concatStringsSep "\n" loginwindow} ${concatStringsSep "\n" smb} ${concatStringsSep "\n" SoftwareUpdate} + ${concatStringsSep "\n" CustomSystemPreferences} ''; system.activationScripts.userDefaults.text = mkIfAttrs @@ -85,6 +89,7 @@ in trackpadBluetooth universalaccess ActivityMonitor + CustomUserPreferences ] '' # Set defaults @@ -104,6 +109,7 @@ in ${concatStringsSep "\n" trackpadBluetooth} ${concatStringsSep "\n" universalaccess} ${concatStringsSep "\n" ActivityMonitor} + ${concatStringsSep "\n" CustomUserPreferences} ''; }; diff --git a/modules/system/defaults/CustomPreferences.nix b/modules/system/defaults/CustomPreferences.nix new file mode 100644 index 0000000..1b4b99b --- /dev/null +++ b/modules/system/defaults/CustomPreferences.nix @@ -0,0 +1,38 @@ +{ config, lib, ... }: + +with lib; + +{ + options = { + system.defaults.CustomUserPreferences = mkOption { + type = types.attrs; + default = { }; + example = { + "NSGlobalDomain" = { "TISRomanSwitchState" = 1; }; + "com.apple.Safari" = { + "com.apple.Safari.ContentPageGroupIdentifier.WebKit2DeveloperExtrasEnabled" = + true; + }; + }; + description = '' + Sets custom user preferences + ''; + }; + + system.defaults.CustomSystemPreferences = mkOption { + type = types.attrs; + default = { }; + example = { + "NSGlobalDomain" = { "TISRomanSwitchState" = 1; }; + "com.apple.Safari" = { + "com.apple.Safari.ContentPageGroupIdentifier.WebKit2DeveloperExtrasEnabled" = + true; + }; + }; + description = '' + Sets custom system preferences + ''; + }; + + }; +} |
