Skip to content

Commit 9175b4b

Browse files
authored
Merge pull request #1377 from zhaofengli/fix-custom-user-preferences-merging
Fix merging of system.defaults.CustomUserPreferences
2 parents 4d8a451 + 814b503 commit 9175b4b

File tree

3 files changed

+45
-10
lines changed

3 files changed

+45
-10
lines changed

modules/system/defaults/CustomPreferences.nix

+18-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,25 @@
22

33
with lib;
44

5-
{
5+
let
6+
valueType = with lib.types; nullOr (oneOf [
7+
bool
8+
int
9+
float
10+
str
11+
path
12+
(attrsOf valueType)
13+
(listOf valueType)
14+
]) // {
15+
description = "plist value";
16+
};
17+
defaultsType = types.submodule {
18+
freeformType = valueType;
19+
};
20+
in {
621
options = {
722
system.defaults.CustomUserPreferences = mkOption {
8-
type = types.attrs;
23+
type = defaultsType;
924
default = { };
1025
example = {
1126
"NSGlobalDomain" = { "TISRomanSwitchState" = 1; };
@@ -20,7 +35,7 @@ with lib;
2035
};
2136

2237
system.defaults.CustomSystemPreferences = mkOption {
23-
type = types.attrs;
38+
type = defaultsType;
2439
default = { };
2540
example = {
2641
"NSGlobalDomain" = { "TISRomanSwitchState" = 1; };

tests/fixtures/system-defaults-write/activate-user.txt

+8
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,14 @@ defaults write NSGlobalDomain 'TISRomanSwitchState' $'<?xml version="1.0" encodi
543543
<plist version="1.0">
544544
<integer>1</integer>
545545
</plist>'
546+
defaults write com.apple.Safari 'NSUserKeyEquivalents' $'<?xml version="1.0" encoding="UTF-8"?>
547+
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
548+
<plist version="1.0">
549+
<dict>
550+
<key>Quit Safari</key>
551+
<string>@^q</string>
552+
</dict>
553+
</plist>'
546554
defaults write com.apple.Safari 'com.apple.Safari.ContentPageGroupIdentifier.WebKit2DeveloperExtrasEnabled' $'<?xml version="1.0" encoding="UTF-8"?>
547555
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
548556
<plist version="1.0">

tests/system-defaults-write.nix

+19-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,25 @@
11
{ config, pkgs, lib, ... }:
22

33
{
4+
imports = [
5+
{
6+
system.defaults.CustomUserPreferences = {
7+
"NSGlobalDomain" = { "TISRomanSwitchState" = 1; };
8+
"com.apple.Safari" = {
9+
"com.apple.Safari.ContentPageGroupIdentifier.WebKit2DeveloperExtrasEnabled" =
10+
true;
11+
};
12+
};
13+
}
14+
{
15+
system.defaults.CustomUserPreferences = {
16+
"com.apple.Safari" = {
17+
"NSUserKeyEquivalents"."Quit Safari" = "@^q"; # Option-Cmd-Q
18+
};
19+
};
20+
}
21+
];
22+
423
system.defaults.NSGlobalDomain.AppleShowAllFiles = true;
524
system.defaults.NSGlobalDomain.AppleEnableMouseSwipeNavigateWithScrolls = false;
625
system.defaults.NSGlobalDomain.AppleEnableSwipeNavigateWithScrolls = false;
@@ -109,13 +128,6 @@
109128
system.defaults.WindowManager.EnableTiledWindowMargins = true;
110129
system.defaults.WindowManager.StandardHideWidgets = true;
111130
system.defaults.WindowManager.StageManagerHideWidgets = true;
112-
system.defaults.CustomUserPreferences = {
113-
"NSGlobalDomain" = { "TISRomanSwitchState" = 1; };
114-
"com.apple.Safari" = {
115-
"com.apple.Safari.ContentPageGroupIdentifier.WebKit2DeveloperExtrasEnabled" =
116-
true;
117-
};
118-
};
119131
system.defaults.controlcenter.BatteryShowPercentage = true;
120132
system.defaults.controlcenter.Sound = false;
121133
system.defaults.controlcenter.Bluetooth = true;

0 commit comments

Comments
 (0)