Nix-Darwin settings are not being applied

Hi!

I’m not sure if this is the best place to ask for help with nix-darwin, but as I’ve gotten good help here before I thought I’d try!

I’m trying to use nix-darwin to set up my new MacBook. I’m trying to use system.defaults.CustomSystemPreferences and/or system.defaults.CustomUserPreferences to configure things that aren’t yet configurable through nix-darwin, for example com.apple.finder.QuitMenuItem.

My problem is that these settings do not seem to get applied, even though other settings (such as which applications to install, with environment.systemPackages, or which shell (Bash) to use) are. I checked the activation script under ./result/activate (after running nix build .#darwinConfigurations.jente@aarch64-darwin.system) and I do find what looks to be the correct calls to defaults:

# Set defaults
echo >&2 "system defaults..."
defaults write /Library/Preferences/com.apple.alf 'globalstate' -int 1
defaults write /Library/Preferences/com.apple.loginwindow 'GuestEnabled' -bool NO


defaults write com.apple.finder 'NewWindowTarget' -string 'PfHm'
defaults write com.apple.finder 'QuitMenuItem' -bool YES
defaults write com.apple.finder 'ShowExternalHardDrivesOnDesktop' -int 1
defaults write com.apple.finder 'ShowHardDrivesOnDesktop' -int 0
defaults write com.apple.finder 'ShowRemovableMediaOnDesktop' -int 1
defaults write com.apple.finder 'ShowSidebar' -int 1

I can run these commands manually and the settings change, but when I do it through nix-darwin (with both darwin-rebuild switch --flake and nix build + ./result/sw/bin/darwin-rebuild) nothing changes (which I confirm with defaults read). I see the echo >&2 "system defaults..." in the output but no further error messages appear. I’ve tried restarting my MacBook after running darwin-rebuild but that doesn’t make a difference unfortunately.

Can someone point out to me what I am missing? My full code is here: Add macOS system by Hjdskes · Pull Request #7 · Hjdskes/system · GitHub.

1 Like

It looks like I’m confusing what’s supposed to be in CustomUserPreferences and CustomSystemPreferences. If I move some things around, the settings are being applied correctly! Now to figure out what goes where!