Compare commits

..

2 Commits

Author SHA1 Message Date
Noah Masur
0b571e4565 partially move macos dock apps to declarative list 2024-02-04 21:09:25 -07:00
Noah Masur
f91c9bcfc2 move macos preferences from imperative to declarative 2024-02-04 13:56:16 -07:00
2 changed files with 67 additions and 59 deletions

View File

@ -11,8 +11,8 @@
config = lib.mkIf (config.gui.enable && config.discord.enable) { config = lib.mkIf (config.gui.enable && config.discord.enable) {
unfreePackages = [ "discord" ]; unfreePackages = [ "discord" ];
environment.systemPackages = [ pkgs.discord ];
home-manager.users.${config.user} = { home-manager.users.${config.user} = {
home.packages = with pkgs; [ discord ];
xdg.configFile."discord/settings.json".text = '' xdg.configFile."discord/settings.json".text = ''
{ {
"BACKGROUND_COLOR": "#202225", "BACKGROUND_COLOR": "#202225",

View File

@ -1,4 +1,4 @@
{ pkgs, lib, ... }: { { config, pkgs, lib, ... }: {
config = lib.mkIf pkgs.stdenv.isDarwin { config = lib.mkIf pkgs.stdenv.isDarwin {
@ -122,79 +122,87 @@
# Where to save screenshots # Where to save screenshots
screencapture.location = "~/Downloads"; screencapture.location = "~/Downloads";
CustomUserPreferences = {
# Disable disk image verification
"com.apple.frameworks.diskimages" = {
skip-verify = true;
skip-verify-locked = true;
skip-verify-remote = true;
};
# Avoid creating .DS_Store files on network or USB volumes
"com.apple.desktopservices" = {
DSDontWriteNetworkStores = true;
DSDontWriteUSBStores = true;
};
"com.apple.dock" = {
magnification = true;
largesize = 48;
persistent-apps = let
dockText = app:
"<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>${app}</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>";
in map dockText [
"/Applications/1Password.app"
"${pkgs.slack}/Applications/Slack.app"
"/System/Applications/Calendar.app"
"${pkgs.firefox-bin}/Applications/Firefox.app"
"/System/Applications/Messages.app"
"/System/Applications/Mail.app"
"/Applications/zoom.us.app"
"${pkgs.discord}/Applications/Discord.app"
"${pkgs.obsidian}/Applications/Obsidian.app"
"${pkgs.kitty}/Applications/kitty.app"
"/System/Applications/System Settings.app"
];
};
# Require password immediately after screen saver begins
"com.apple.screensaver" = {
askForPassword = 1;
askForPasswordDelay = 0;
};
"com.apple.finder" = {
# Disable the warning before emptying the Trash
WarnOnEmptyTrash = false;
# Finder search in current folder by default
FXDefaultSearchScope = "SCcf";
# Default Finder window set to column view
FXPreferredViewStyle = "clmv";
};
"leits.MeetingBar" = {
eventTimeFormat = ''"show"'';
eventTitleFormat = ''"none"'';
eventTitleIconFormat = ''"iconCalendar"'';
slackBrowser =
''{"deletable":true,"arguments":"","name":"Slack","path":""}'';
zoomBrowser =
''{"deletable":true,"arguments":"","name":"Zoom","path":""}'';
KeyboardShortcuts_joinEventShortcut =
''{"carbonModifiers":6400,"carbonKeyCode":38}'';
};
};
}; };
# Settings that don't have an option in nix-darwin # Settings that don't have an option in nix-darwin
activationScripts.postActivation.text = '' activationScripts.postActivation.text = ''
echo "Disable disk image verification"
defaults write com.apple.frameworks.diskimages skip-verify -bool true
defaults write com.apple.frameworks.diskimages skip-verify-locked -bool true
defaults write com.apple.frameworks.diskimages skip-verify-remote -bool true
echo "Avoid creating .DS_Store files on network volumes"
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
echo "Disable the warning before emptying the Trash"
defaults write com.apple.finder WarnOnEmptyTrash -bool false
echo "Require password immediately after sleep or screen saver begins"
defaults write com.apple.screensaver askForPassword -int 1
defaults write com.apple.screensaver askForPasswordDelay -int 0
echo "Allow apps from anywhere" echo "Allow apps from anywhere"
SPCTL=$(spctl --status) SPCTL=$(spctl --status)
if ! [ "$SPCTL" = "assessments disabled" ]; then if ! [ "$SPCTL" = "assessments disabled" ]; then
sudo spctl --master-disable sudo spctl --master-disable
fi fi
''; '';
# User-level settings # User-level settings
activationScripts.postUserActivation.text = '' activationScripts.postUserActivation.text = let
persistentApps = lib.concatMapStrings (x: ''"'' + x + ''" '')
config.system.defaults.CustomUserPreferences."com.apple.dock".persistent-apps;
in ''
echo "Show the ~/Library folder" echo "Show the ~/Library folder"
chflags nohidden ~/Library chflags nohidden ~/Library
if [ ! $(defaults read com.apple.dock magnification) = "1" ]; then
echo "Enable dock magnification"
defaults write com.apple.dock magnification -bool true
fi
if [ ! $(defaults read com.apple.dock largesize) = "48" ]; then
echo "Set dock magnification size"
defaults write com.apple.dock largesize -int 48
fi
echo "Define dock icon function"
__dock_item() {
printf "%s%s%s%s%s" \
"<dict><key>tile-data</key><dict><key>file-data</key><dict>" \
"<key>_CFURLString</key><string>" \
"$1" \
"</string><key>_CFURLStringType</key><integer>0</integer>" \
"</dict></dict></dict>"
}
echo "Choose and order dock icons" echo "Choose and order dock icons"
defaults write com.apple.dock persistent-apps -array \ defaults write com.apple.dock persistent-apps -array ${persistentApps}
"$(__dock_item /Applications/1Password.app)" \
"$(__dock_item ${pkgs.slack}/Applications/Slack.app)" \
"$(__dock_item /System/Applications/Calendar.app)" \
"$(__dock_item ${pkgs.firefox-bin}/Applications/Firefox.app)" \
"$(__dock_item /System/Applications/Messages.app)" \
"$(__dock_item /System/Applications/Mail.app)" \
"$(__dock_item /Applications/zoom.us.app)" \
"$(__dock_item ${pkgs.discord}/Applications/Discord.app)" \
"$(__dock_item ${pkgs.obsidian}/Applications/Obsidian.app)" \
"$(__dock_item ${pkgs.kitty}/Applications/kitty.app)" \
"$(__dock_item /System/Applications/System\ Settings.app)"
echo "MeetingBar settings"
defaults write leits.MeetingBar eventTimeFormat -string "\"show\""
defaults write leits.MeetingBar eventTitleFormat -string "\"none\""
defaults write leits.MeetingBar eventTitleIconFormat -string "\"iconCalendar\""
defaults write leits.MeetingBar slackBrowser -string "{\"deletable\":true,\"arguments\":\"\",\"name\":\"Slack\",\"path\":\"\"}"
defaults write leits.MeetingBar zoomBrowser -string "{\"deletable\":true,\"arguments\":\"\",\"name\":\"Zoom\",\"path\":\"\"}"
defaults write leits.MeetingBar KeyboardShortcuts_joinEventShortcut -string "{\"carbonModifiers\":6400,\"carbonKeyCode\":38}"
''; '';
}; };