-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
targets/darwin: add more options for configuring macOS #1753
Conversation
Are the feature implemented here overlapping with Nix Darwin? |
Perhaps yes, though I'm not aware of the specifics of what nix-darwin provides. The features introduced here are solely focused on settings for the current user, so I believe this falls within the scope of Home Manager.
|
reverted |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution
This option would make it possible to add additional descriptions, type infomation, and default values for individual options in 'targets.darwin.defaultSchema'.
This reverts commit 2bf0feb.
2bf0feb
to
4043a11
Compare
Few things left to change and it's good to go! |
toDefaultsFile = domain: attrs: | ||
pkgs.writeText "${domain}.plist" (lib.generators.toPlist { } attrs); | ||
|
||
toActivationCmd = domain: attrs: | ||
"$DRY_RUN_CMD defaults import ${escapeShellArg domain} ${ | ||
toDefaultsFile domain attrs | ||
}"; | ||
|
||
nonNullDefaults = | ||
mapAttrs (domain: attrs: (filterAttrs (n: v: v != null) attrs)) | ||
cfg.defaults; | ||
writableDefaults = filterAttrs (domain: attrs: attrs != { }) nonNullDefaults; | ||
activationCmds = mapAttrsToList toActivationCmd writableDefaults; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the logic here a little so that it won't perform a defaults import
when the target domain includes only null values. So for example, when a user has the following configuration, it won't perform a defaults import com.apple.desktopservices
:
{ "com.apple.desktopservices".DSDontWriteNetworkStores = null; }
The previous behavior should be harmless, but it might confuse users running Home Manager with verbose output.
Thanks for the contribution! |
This was upstreamed as 'targets.darwin' in nix-community/home-manager#1753
I kind off hoped that this would be defined Note that this is an opinion from a recent user's point of view. Edit: This is more of my take on nix-darwin/home-manager interactions and not specific to this PR 🙂 |
…#1753) Add new options Darwin options: - `targets.darwin.defaults` This adds options for configuring macOS through the `defaults(1)` system. This option can be used to manipulate a vast majority of user settings for macOS and its applications. This is implemented using freeform modules and includes additional descriptions and type information for some useful options. - `targets.darwin.keybindings` This adds options for configuring the default keybindings for macOS text fields. - `targets.darwin.search` This adds options for configuring the default search engine for macOS.
…#1753) Add new options Darwin options: - `targets.darwin.defaults` This adds options for configuring macOS through the `defaults(1)` system. This option can be used to manipulate a vast majority of user settings for macOS and its applications. This is implemented using freeform modules and includes additional descriptions and type information for some useful options. - `targets.darwin.keybindings` This adds options for configuring the default keybindings for macOS text fields. - `targets.darwin.search` This adds options for configuring the default search engine for macOS.
…#1753) Add new options Darwin options: - `targets.darwin.defaults` This adds options for configuring macOS through the `defaults(1)` system. This option can be used to manipulate a vast majority of user settings for macOS and its applications. This is implemented using freeform modules and includes additional descriptions and type information for some useful options. - `targets.darwin.keybindings` This adds options for configuring the default keybindings for macOS text fields. - `targets.darwin.search` This adds options for configuring the default search engine for macOS.
Description
This adds the following new options:
targets.darwin.defaults
This adds options for configuring macOS through the
defaults(1)
system. This option can be used to manipulate a vast majority of user settings for macOS and its applications.This is implemented using freeform modules and includes additional descriptions and type information for some useful options.
targets.darwin.keybindings
This adds options for configuring the default keybindings for macOS text fields.
targets.darwin.search
This adds options for configuring the default search engine for macOS.
Checklist
Change is backwards compatible.
Code formatted with
./format
.Code tested through
nix-shell --pure tests -A run.all
.Test cases updated/added. See example.
Commit messages are formatted like
See CONTRIBUTING for more information and recent commit messages for examples.