-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: use platform helpers to set defaults (#4)
Replace our internal logic in favor of using nix-darwin's `system.defaults.CustomUserPreferences` or home-manager's `targets.darwin.defaults`. We still take care of deletion as usual. Nothing changed functionality-wise. Why? - Less logic to maintain - Slightly easier to spot conflicts e.g. if a user sets a value with plist-manager and a different one with `system.defaults.CustomUserPreferences` nix should catch that during the build.
- Loading branch information
Showing
5 changed files
with
71 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
{ config, pkgs, ... }: | ||
|
||
let | ||
script = pkgs.writeShellScript "plist-darwin-activate" config.plist.out; | ||
fail = msg: "(printf '\\033[0;31m${msg}\\033[0m\n' && exit 1)"; | ||
in | ||
{ config, ... }: | ||
|
||
{ | ||
imports = [ | ||
../modules | ||
]; | ||
|
||
system.defaults.CustomUserPreferences = config.plist.out; | ||
|
||
system.activationScripts.postActivation.text = '' | ||
echo "Activating plistManager" | ||
echo "└── Using ${script}" | ||
${script} || ${fail "Failed to run ${script}"} | ||
${config.plist.purgeScript} | ||
# Reload settings | ||
/System/Library/PrivateFrameworks/SystemAdministration.framework/Resources/activateSettings -u | ||
''; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
{ config, pkgs, lib, ... }: | ||
|
||
let | ||
script = pkgs.writeShellScript "plist-home-activate" config.plist.out; | ||
fail = msg: "(printf '\\033[0;31m${msg}\\033[0m\n' && exit 1)"; | ||
in | ||
{ config, lib, ... }: | ||
|
||
{ | ||
imports = [ | ||
../modules | ||
]; | ||
|
||
targets.darwin.defaults = config.plist.out; | ||
|
||
home.activation.plistManager = lib.hm.dag.entryAfter [ "setDarwinDefaults" ] '' | ||
echo "└── Using ${script}" | ||
run ${script} || ${fail "Failed to run ${script}"} | ||
set -e | ||
${config.plist.purgeScript} | ||
# Reload settings | ||
/System/Library/PrivateFrameworks/SystemAdministration.framework/Resources/activateSettings -u | ||
''; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters