1
0
Fork 0
mirror of https://github.com/LnL7/nix-darwin.git synced 2025-03-31 04:04:45 +00:00
This commit is contained in:
Angel J 2025-03-29 15:35:56 +00:00 committed by GitHub
commit 5e345c7150
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 561 additions and 80 deletions

View file

@ -15,6 +15,7 @@
./system/applications.nix
./system/defaults-write.nix
./system/defaults/controlcenter.nix
./system/defaults/Spotlight.nix
./system/defaults/LaunchServices.nix
./system/defaults/NSGlobalDomain.nix
./system/defaults/GlobalPreferences.nix

View file

@ -38,6 +38,7 @@ let
ActivityMonitor = defaultsToList "com.apple.ActivityMonitor" cfg.ActivityMonitor;
WindowManager = defaultsToList "com.apple.WindowManager" cfg.WindowManager;
controlcenter = defaultsToList "~/Library/Preferences/ByHost/com.apple.controlcenter" cfg.controlcenter;
Spotlight = defaultsToList "~/Library/Preferences/ByHost/com.apple.Spotlight" cfg.Spotlight;
CustomUserPreferences = flatten (mapAttrsToList (name: value: defaultsToList name value) cfg.CustomUserPreferences);
CustomSystemPreferences = flatten (mapAttrsToList (name: value: defaultsToList name value) cfg.CustomSystemPreferences);
@ -95,6 +96,7 @@ in
CustomUserPreferences
WindowManager
controlcenter
Spotlight
]
''
# Set defaults
@ -120,6 +122,7 @@ in
${concatStringsSep "\n" CustomUserPreferences}
${concatStringsSep "\n" WindowManager}
${concatStringsSep "\n" controlcenter}
${concatStringsSep "\n" Spotlight}
${optionalString (length dock > 0) ''
# Only restart Dock if current user is logged in

View file

@ -0,0 +1,20 @@
{ config, lib, ... }:
{
options = {
system.defaults.Spotlight.MenuItemHidden = lib.mkOption {
type = lib.types.nullOr lib.types.bool;
default = null;
description = ''
Show Spotlight control in menu bar.
Available settings:
true - Don't Show in Menu Bar
false - Show in Menu Bar
This option mirrors the setting found in:
System Preferences > Control Center > Menu Bar Only > Spotlight
'';
};
};
}

View file

@ -1,100 +1,484 @@
{ config, lib, ... }:
let
mkEnumApply =
mapping: default: v:
if v == null then
null
else if builtins.isBool v then
if v then mapping.true else mapping.false
else if mapping ? v then
mapping.${v}
else
default;
mkBoolApply =
mapping: v:
if v == null then
null
else if v then
mapping.true
else
mapping.false;
in
{
options = {
system.defaults.controlcenter.BatteryShowPercentage = lib.mkOption {
type = lib.types.nullOr lib.types.bool;
default = null;
description = ''
Apple menu > System Preferences > Control Center > Battery
system.defaults.controlcenter.AccessibilityShortcuts = lib.mkOption {
type = lib.types.nullOr (
lib.types.enum [
"both"
"menuBar"
"controlCenter"
"hide"
]
);
default = null;
apply = mkEnumApply {
both = 3;
menuBar = 6;
controlCenter = 9;
hide = 12;
} 12;
description = ''
Show an Accessibility Shortcuts control in menu bar.
Show a battery percentage in menu bar. Default is null.
'';
};
Available settings:
both - Show in both the Menu Bar and Control Center (3)
menuBar - Show in the Menu Bar only (6)
controlCenter - Show in Control Center only (9)
hide - Don't Show (12)
system.defaults.controlcenter.Sound = lib.mkOption {
type = lib.types.nullOr lib.types.bool;
apply = v: if v == null then null else if v == true then 18 else 24;
default = null;
description = ''
Apple menu > System Preferences > Control Center > Sound
Show a sound control in menu bar . Default is null.
18 = Display icon in menu bar
24 = Hide icon in menu bar
'';
};
system.defaults.controlcenter.Bluetooth = lib.mkOption {
type = lib.types.nullOr lib.types.bool;
apply = v: if v == null then null else if v == true then 18 else 24;
default = null;
description = ''
Apple menu > System Preferences > Control Center > Bluetooth
Show a bluetooth control in menu bar. Default is null.
18 = Display icon in menu bar
24 = Hide icon in menu bar
'';
This option mirrors the setting found in:
System Preferences > Control Center > AccessibilityShortcuts
'';
};
system.defaults.controlcenter.AirDrop = lib.mkOption {
type = lib.types.nullOr lib.types.bool;
apply = v: if v == null then null else if v == true then 18 else 24;
default = null;
description = ''
Apple menu > System Preferences > Control Center > AirDrop
type = lib.types.nullOr lib.types.bool;
default = null;
apply = mkBoolApply {
true = 18;
false = 24;
};
description = ''
Show an AirDrop control in menu bar.
Show a AirDrop control in menu bar. Default is null.
Available settings:
true - Show in Menu Bar (18)
false - Don't Show in Menu Bar (24)
18 = Display icon in menu bar
24 = Hide icon in menu bar
'';
This option mirrors the setting found in:
System Preferences > Control Center > AirDrop
'';
};
system.defaults.controlcenter.Battery = lib.mkOption {
type = lib.types.nullOr (
lib.types.enum [
"both"
"menuBar"
"controlCenter"
"hide"
]
);
default = null;
apply = mkEnumApply {
both = 3;
menuBar = 4;
controlCenter = 9;
hide = 12;
} 4;
description = ''
Show a Battery control in menu bar.
Available settings:
both - Show in both the Menu Bar and Control Center (3)
menuBar - Show in the Menu Bar only (4)
controlCenter - Show in Control Center only (9)
hide - Don't Show (12)
This option mirrors the setting found in:
System Preferences > Control Center > Battery
'';
};
system.defaults.controlcenter.BatteryShowEnergyMode = lib.mkOption {
type = lib.types.nullOr (
lib.types.enum [
"whenActive"
"always"
]
);
default = null;
apply = mkEnumApply {
always = true;
whenActive = false;
} false;
description = ''
Show a Battery Energy Mode control in menu bar.
Available settings:
whenActive - Show When Active
always - Always Show
This option mirrors the setting found in:
System Preferences > Control Center > Battery
'';
};
system.defaults.controlcenter.BatteryShowPercentage = lib.mkOption {
type = lib.types.nullOr lib.types.bool;
default = null;
description = ''
Show a Battery Percentage control in menu bar.
Available settings:
true - Show in Menu Bar
false - Don't Show in Menu Bar
This option mirrors the setting found in:
System Preferences > Control Center > Battery
'';
};
system.defaults.controlcenter.Bluetooth = lib.mkOption {
type = lib.types.nullOr lib.types.bool;
default = null;
apply = mkBoolApply {
true = 18;
false = 24;
};
description = ''
Show a Bluetooth control in menu bar.
Available settings:
true - Show in Menu Bar (18)
false - Don't Show in Menu Bar (24)
This option mirrors the setting found in:
System Preferences > Control Center > Bluetooth
'';
};
system.defaults.controlcenter.Display = lib.mkOption {
type = lib.types.nullOr lib.types.bool;
apply = v: if v == null then null else if v == true then 18 else 24;
default = null;
description = ''
Apple menu > System Preferences > Control Center > Display
type = lib.types.nullOr (
lib.types.enum [
"whenActive"
"hide"
"always"
true
false
]
);
default = null;
apply = mkEnumApply {
always = 18;
hide = 8;
whenActive = 2;
Show a Screen Brightness control in menu bar. Default is null.
true = lib.warn "system.defaults.controlcenter.Display = true is deprecated; please use \"always\" instead" 18;
false = lib.warn "system.defaults.controlcenter.Display = false is deprecated; please use \"whenActive\" instead" 2;
} 2;
description = ''
Show a Display control in menu bar.
18 = Display icon in menu bar
24 = Hide icon in menu bar
'';
Available settings:
whenActive - Show When Active (2)
hide - Don't Show in Menu Bar (8)
always - Always Show in Menu Bar (18)
Note: Boolean values are deprecated; please use the enum values.
This option mirrors the setting found in:
System Preferences > Control Center > Display
'';
};
system.defaults.controlcenter.FocusModes = lib.mkOption {
type = lib.types.nullOr lib.types.bool;
apply = v: if v == null then null else if v == true then 18 else 24;
default = null;
description = ''
Apple menu > System Preferences > Control Center > Focus
type = lib.types.nullOr (
lib.types.enum [
"whenActive"
"hide"
"always"
true
false
]
);
default = null;
apply = mkEnumApply {
always = 18;
hide = 8;
whenActive = 2;
Show a Focus control in menu bar. Default is null.
true = lib.warn "system.defaults.controlcenter.FocusModes = true is deprecated; please use \"always\" instead" 18;
false = lib.warn "system.defaults.controlcenter.FocusModes = false is deprecated; please use \"whenActive\" instead" 2;
} 2;
description = ''
Show a Focus control in menu bar.
18 = Display icon in menu bar
24 = Hide icon in menu bar
'';
Available settings:
whenActive - Show When Active (2)
hide - Don't Show in Menu Bar (8)
always - Always Show in Menu Bar (18)
Note: Boolean values are deprecated; please use the enum values.
This option mirrors the setting found in:
System Preferences > Control Center > Focus
'';
};
system.defaults.controlcenter.Hearing = lib.mkOption {
type = lib.types.nullOr (
lib.types.enum [
"both"
"menuBar"
"controlCenter"
"hide"
]
);
default = null;
apply = mkEnumApply {
both = 3;
menuBar = 6;
controlCenter = 9;
hide = 12;
} 12;
description = ''
Show a Hearing control in menu bar.
Available settings:
both - Show in both the Menu Bar and Control Center (3)
menuBar - Show in the Menu Bar only (6)
controlCenter - Show in Control Center only (9)
hide - Don't Show (12)
This option mirrors the setting found in:
System Preferences > Control Center > Hearing
'';
};
system.defaults.controlcenter.KeyboardBrightness = lib.mkOption {
type = lib.types.nullOr (
lib.types.enum [
"both"
"menuBar"
"controlCenter"
"hide"
]
);
default = null;
apply = mkEnumApply {
both = 3;
menuBar = 6;
controlCenter = 9;
hide = 12;
} 12;
description = ''
Show a Keyboard Brightness control in menu bar.
Available settings:
both - Show in both the Menu Bar and Control Center (3)
menuBar - Show in the Menu Bar only (6)
controlCenter - Show in Control Center only (9)
hide - Don't Show (12)
This option mirrors the setting found in:
System Preferences > Control Center > Keyboard Brightness
'';
};
system.defaults.controlcenter.MusicRecognition = lib.mkOption {
type = lib.types.nullOr (
lib.types.enum [
"both"
"menuBar"
"controlCenter"
"hide"
]
);
default = null;
apply = mkEnumApply {
both = 3;
menuBar = 6;
controlCenter = 9;
hide = 12;
} 12;
description = ''
Show a Music Recognition control in menu bar.
Available settings:
both - Show in both the Menu Bar and Control Center (3)
menuBar - Show in the Menu Bar only (6)
controlCenter - Show in Control Center only (9)
hide - Don't Show (12)
This option mirrors the setting found in:
System Preferences > Control Center > Music Recognition
'';
};
system.defaults.controlcenter.NowPlaying = lib.mkOption {
type = lib.types.nullOr lib.types.bool;
apply = v: if v == null then null else if v == true then 18 else 24;
default = null;
description = ''
Apple menu > System Preferences > Control Center > Now Playing
type = lib.types.nullOr (
lib.types.enum [
"whenActive"
"hide"
"always"
true
false
]
);
default = null;
apply = mkEnumApply {
always = 18;
hide = 8;
whenActive = 2;
Show a Now Playing control in menu bar. Default is null.
true = lib.warn "system.defaults.controlcenter.NowPlaying = true is deprecated; please use \"always\" instead" 18;
false = lib.warn "system.defaults.controlcenter.NowPlaying = false is deprecated; please use \"whenActive\" instead" 2;
} 2;
description = ''
Show a Now Playing control in menu bar.
18 = Display icon in menu bar
24 = Hide icon in menu bar
'';
Available settings:
whenActive - Show When Active (2)
hide - Don't Show in Menu Bar (8)
always - Always Show in Menu Bar (18)
Note: Boolean values are deprecated; please use the enum values.
This option mirrors the setting found in:
System Preferences > Control Center > Now Playing
'';
};
system.defaults.controlcenter.ScreenMirroring = lib.mkOption {
type = lib.types.nullOr (
lib.types.enum [
"whenActive"
"hide"
"always"
]
);
default = null;
apply = mkEnumApply {
always = 18;
hide = 8;
whenActive = 2;
} 2;
description = ''
Show a Screen Mirroring control in menu bar.
Available settings:
whenActive - Show When Active (2)
hide - Don't Show in Menu Bar (8)
always - Always Show in Menu Bar (18)
This option mirrors the setting found in:
System Preferences > Control Center > Screen Mirroring
'';
};
system.defaults.controlcenter.Sound = lib.mkOption {
type = lib.types.nullOr (
lib.types.enum [
"whenActive"
"hide"
"always"
true
false
]
);
default = null;
apply = mkEnumApply {
always = 18;
hide = 8;
whenActive = 2;
true = lib.warn "system.defaults.controlcenter.Sound = true is deprecated; please use \"always\" instead" 18;
false = lib.warn "system.defaults.controlcenter.Sound = false is deprecated; please use \"whenActive\" instead" 2;
} 2;
description = ''
Show a Sound control in menu bar.
Available settings:
whenActive - Show When Active (2)
hide - Don't Show in Menu Bar (8)
always - Always Show in Menu Bar (18)
Note: Boolean values are deprecated; please use the enum values.
This option mirrors the setting found in:
System Preferences > Control Center > Sound
'';
};
system.defaults.controlcenter.StageManager = lib.mkOption {
type = lib.types.nullOr lib.types.bool;
default = null;
apply = mkBoolApply {
true = 2;
false = 8;
};
description = ''
Show a Stage Manager control in menu bar.
Available settings:
true - Show in Menu Bar (2)
false - Don't Show in Menu Bar (8)
This option mirrors the setting found in:
System Preferences > Control Center > Stage Manager
'';
};
system.defaults.controlcenter.UserSwitcher = lib.mkOption {
type = lib.types.nullOr (
lib.types.enum [
"both"
"menuBar"
"controlCenter"
"hide"
]
);
default = null;
apply = mkEnumApply {
both = 19;
menuBar = 22;
controlCenter = 25;
hide = 28;
} 28;
description = ''
Show a User Switcher control in menu bar.
Available settings:
both - Show in both the Menu Bar and Control Center (19)
menuBar - Show in the Menu Bar only (22)
controlCenter - Show in Control Center only (25)
hide - Don't Show (28)
This option mirrors the setting found in:
System Preferences > Control Center > Fast User Switching
'';
};
system.defaults.controlcenter.WiFi = lib.mkOption {
type = lib.types.nullOr lib.types.bool;
default = null;
apply = mkBoolApply {
true = 18;
false = 24;
};
description = ''
Show a Wi-Fi control in menu bar.
Available settings:
true - Show in Menu Bar (18)
false - Don't Show in Menu Bar (24)
This option mirrors the setting found in:
System Preferences > Control Center > Wi-Fi
'';
};
};
}

View file

@ -616,11 +616,26 @@ defaults write com.apple.WindowManager 'StandardHideWidgets' $'<?xml version="1.
<plist version="1.0">
<true/>
</plist>'
defaults write ~/Library/Preferences/ByHost/com.apple.controlcenter 'AccessibilityShortcuts' $'<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<integer>3</integer>
</plist>'
defaults write ~/Library/Preferences/ByHost/com.apple.controlcenter 'AirDrop' $'<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<integer>18</integer>
</plist>'
defaults write ~/Library/Preferences/ByHost/com.apple.controlcenter 'Battery' $'<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<integer>4</integer>
</plist>'
defaults write ~/Library/Preferences/ByHost/com.apple.controlcenter 'BatteryShowEnergyMode' $'<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<true/>
</plist>'
defaults write ~/Library/Preferences/ByHost/com.apple.controlcenter 'BatteryShowPercentage' $'<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
@ -634,20 +649,60 @@ defaults write ~/Library/Preferences/ByHost/com.apple.controlcenter 'Bluetooth'
defaults write ~/Library/Preferences/ByHost/com.apple.controlcenter 'Display' $'<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<integer>24</integer>
<integer>18</integer>
</plist>'
defaults write ~/Library/Preferences/ByHost/com.apple.controlcenter 'FocusModes' $'<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<integer>24</integer>
<integer>18</integer>
</plist>'
defaults write ~/Library/Preferences/ByHost/com.apple.controlcenter 'Hearing' $'<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<integer>6</integer>
</plist>'
defaults write ~/Library/Preferences/ByHost/com.apple.controlcenter 'KeyboardBrightness' $'<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<integer>6</integer>
</plist>'
defaults write ~/Library/Preferences/ByHost/com.apple.controlcenter 'MusicRecognition' $'<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<integer>6</integer>
</plist>'
defaults write ~/Library/Preferences/ByHost/com.apple.controlcenter 'NowPlaying' $'<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<integer>18</integer>
</plist>'
defaults write ~/Library/Preferences/ByHost/com.apple.controlcenter 'ScreenMirroring' $'<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<integer>18</integer>
</plist>'
defaults write ~/Library/Preferences/ByHost/com.apple.controlcenter 'Sound' $'<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<integer>24</integer>
<integer>18</integer>
</plist>'
defaults write ~/Library/Preferences/ByHost/com.apple.controlcenter 'StageManager' $'<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<integer>2</integer>
</plist>'
defaults write ~/Library/Preferences/ByHost/com.apple.controlcenter 'UserSwitcher' $'<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<integer>22</integer>
</plist>'
defaults write ~/Library/Preferences/ByHost/com.apple.controlcenter 'WiFi' $'<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<integer>18</integer>
</plist>'
defaults write ~/Library/Preferences/ByHost/com.apple.Spotlight 'MenuItemHidden' $'<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<true/>
</plist>'

View file

@ -128,13 +128,31 @@
system.defaults.WindowManager.EnableTiledWindowMargins = true;
system.defaults.WindowManager.StandardHideWidgets = true;
system.defaults.WindowManager.StageManagerHideWidgets = true;
system.defaults.controlcenter.BatteryShowPercentage = true;
system.defaults.controlcenter.Sound = false;
system.defaults.controlcenter.Bluetooth = true;
system.defaults.CustomUserPreferences = {
"NSGlobalDomain" = { "TISRomanSwitchState" = 1; };
"com.apple.Safari" = {
"com.apple.Safari.ContentPageGroupIdentifier.WebKit2DeveloperExtrasEnabled" =
true;
};
};
system.defaults.controlcenter.AccessibilityShortcuts = "both";
system.defaults.controlcenter.AirDrop = true;
system.defaults.controlcenter.Display = false;
system.defaults.controlcenter.FocusModes = false;
system.defaults.controlcenter.NowPlaying = true;
system.defaults.controlcenter.Battery = "both";
system.defaults.controlcenter.BatteryShowEnergyMode = "always";
system.defaults.controlcenter.BatteryShowPercentage = true;
system.defaults.controlcenter.Bluetooth = true;
system.defaults.controlcenter.Display = "always";
system.defaults.controlcenter.FocusModes = "always";
system.defaults.controlcenter.Hearing = "both";
system.defaults.controlcenter.KeyboardBrightness = "both";
system.defaults.controlcenter.MusicRecognition = "both";
system.defaults.controlcenter.NowPlaying = "always";
system.defaults.controlcenter.ScreenMirroring = "always";
system.defaults.controlcenter.Sound = "always";
system.defaults.controlcenter.StageManager = true;
system.defaults.controlcenter.UserSwitcher = "both";
system.defaults.controlcenter.WiFi = true;
system.defaults.Spotlight.MenuItemHidden = true;
test = lib.strings.concatMapStringsSep "\n"
(x: ''
echo >&2 "checking defaults write in /${x}"