nix-darwin icon indicating copy to clipboard operation
nix-darwin copied to clipboard

system.defaults settings not activated on switch

Open zhengpd opened this issue 1 year ago • 8 comments

The system.defaults.trackpad.Clicking = true; does not get activated on darwin-rebuild switch --flake .. It can be activated immediately with /System/Library/PrivateFrameworks/SystemAdministration.framework/Resources/activateSettings -u. Could we make nix-darwin to activate by default on switching?

zhengpd avatar May 14 '23 21:05 zhengpd

same issue here. other options(ex. time.timeZone) works correctly but system.defaults.* options don't work.
I'm currently using MacBook Pro(M2, Ventura 13.4)

eunsukimme avatar May 22 '23 16:05 eunsukimme

I know certain options require killing the Finder or Dock process to apply, but doing so makes windows jump around, etc. so that would be kind of annoying to do every rebuild. This is the first time I've seen that activateSettings command, if that's a way to emulate whatever the UI does adding it would be a nice improvement.

LnL7 avatar May 22 '23 17:05 LnL7

I guess it would go here? https://github.com/LnL7/nix-darwin/blob/bc346a67d34a336ca3c507570875cc88038e6120/modules/system/defaults-write.nix#L120

But I came across some thoughts from 2019 about whether that binary actually applies all of the settings, and the author wasn't convinced: https://assert.cc/posts/maybe-dont-script-macos-prefs/

purcell avatar Jun 22 '23 13:06 purcell

I'm not seeing system.defaults being applied at all, is there an extra step that I'm missing? I followed the flake install instructions

mhanberg avatar Jul 17 '23 14:07 mhanberg

Should just work for most things. Some things require a logout/reboot to activate, unfortunately, and some seemingly don't even set properly via the defaults interface at all (but if that applies to any we expose it's a bug). Can you show your configuration, or at least the relevant defaults parts of it? Does simple stuff work (e.g. system.defaults.dock.orientation = "right";, activate, then killall Dock)? Do you get any errors when activating your configuration?

emilazy avatar Jul 17 '23 15:07 emilazy

it seems like running killall Dock was the fix for me, except that setting AppleInterfaceStyle to null doesn't actually do anything (i confirmed with defaults read -g AppleInterfaceStyle, which still says "Dark" rather than 2023-07-17 12:46:50.801 defaults[16422:158718] The domain/default pair of (kCFPreferencesAnyApplication, AppleInterfaceStyle) does not exist)

mhanberg avatar Jul 17 '23 16:07 mhanberg

Yes, that's a really unfortunate problem with our defaults system: we do not track any state and therefore null does not mean "unset" (as that would delete all your existing defaults on first activation), but "leave at current value". Unfortunately there is nothing you can do here as a user other than explicitly delete defaults when you no longer want them.

I think that this is an unacceptable compromise and should be fixed, but it's non-trivial to do so. Ultimately nix-darwin can never be as perfectly hermetic as something like NixOS which controls the entire system; there's often a trade-off between what functionality we offer, the implementation complexity and fragility involved, and upholding full declarativity. Sorry that we failed on the latter here and I hope to work on more strongly prioritizing it in the future.

emilazy avatar Jul 17 '23 16:07 emilazy

it's no problem, I appreciate the help here! just getting started with nix and nix-darwin, so this makes sense in hindsight.

thanks!

mhanberg avatar Jul 17 '23 16:07 mhanberg