From f973dd261f3714ca4bf920dcdabb8f90a8fc61cf Mon Sep 17 00:00:00 2001 From: "Thomas A. Christensen II" <25492070+MillironX@users.noreply.github.com> Date: Sun, 2 Nov 2025 23:06:29 -0600 Subject: [PATCH 1/3] fix (Taskbar.app): Update settings to post-reset --- programs/taskbar.nix | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/programs/taskbar.nix b/programs/taskbar.nix index 992c1f6..2906289 100644 --- a/programs/taskbar.nix +++ b/programs/taskbar.nix @@ -1,8 +1,8 @@ { ... }: { defaults."Taskbar" = { - centerTasksAndButtons = false; - hideReviewOptions = true; - permissionsResetOnce = true; + centerTasksAndButtons = 0; + hideReviewOptions = 1; + permissionsResetOnce = 1; pinList = [ { action = "finderNewWindow"; @@ -22,11 +22,15 @@ } { action = "launchOrActivateApp"; - bundleIdentifier = "com.electron.logseq"; + bundleIdentifier = "org.mozilla.thunderbird"; } { action = "launchOrActivateApp"; - bundleIdentifier = "org.mozilla.thunderbird"; + bundleIdentifier = "com.electron.logseq"; + } + { + action = "lauchOrActivateApp"; + bundleIdentifier = "dev.zed.Zed"; } { action = "launchOrActivateApp"; @@ -39,11 +43,11 @@ "com.apple.Safari.WebApp.5EC6478E-03A6-4147-8A4D-6EF3DE3F06D3"; } ]; - sendCrashReports = true; - showMenubarIcon = false; - showThumbnails = true; - showWindowTitleInThumbails = true; + sendCrashReports = 1; + showMenubarIcon = 0; + showThumbnails = 1; + showWindowTitleInThumbails = 1; taskViewMaxWidth = 200; - updatePolicy = 0; + updatePolicy = 2; }; } From 03e0863ec87e8e29afe99ff1671afebdfdaad4e5 Mon Sep 17 00:00:00 2001 From: "Thomas A. Christensen II" <25492070+MillironX@users.noreply.github.com> Date: Mon, 3 Nov 2025 10:29:31 -0600 Subject: [PATCH 2/3] refactor (defaults): nix-darwin-like plist handling A bug in Taskbar.app led to me switching out the defaults module for something more like what nix-darwin has. Future testing leads me to believe that the toPlist system was less of a problem, but this is more robust anyway, so I'll keep it. --- modules/defaults.nix | 58 ++++++++++---------------------------------- 1 file changed, 13 insertions(+), 45 deletions(-) diff --git a/modules/defaults.nix b/modules/defaults.nix index dd5b2d7..6bff1bb 100644 --- a/modules/defaults.nix +++ b/modules/defaults.nix @@ -1,56 +1,24 @@ -# WARNING: This module was "vibe coded" by Claude Sonnet 4.5 Thinking -# Nix modules are mostly boilerplace, so the logic is (mostly) mine, and the -# rest comes from Claude. For reference, here was my prompt: -# -# I would like to write a new module for managing MacOS apps via the `defaults` -# cli. Ideally, the syntax that I want to include in my home-manager config -# should look like: -# -# ```nix -# darwin-defaults = { -# "com.fpfxtknjju.wbgcdolfev" = { -# centerTasksAndButtons = false; -# pinList = [ -# { action = "finderNewWindow"; bundleIdentifier = "com.apple.finder"; } -# { action = "firefoxNewWindow"; bundleIdentifier = "org.mozilla.firefox"; } -# { action = "launchOrActivateApp"; bundleIdentifier = "com.electron.logseq"; } -# ]; -# }; -# "com.lwouis.alt-tab-macos" = { -# screenRecordingPermissionSkipped = true; -# nextWindowGesture = 1; -# }; -# }; -# ``` -# -# This should be fairly easy to implement, as `defaults` accepts (escaped) plist -# strings, and Nix provides lib.generators.toPlist. Can you help me write the -# module, please? - { config, lib, pkgs, ... }: let inherit (pkgs.stdenv.hostPlatform) isDarwin; inherit (lib) mkOption types mkIf; inherit (lib.generators) toPlist; + writeDefault = app: key: value: + "/usr/bin/defaults write -app ${app} '${key}' $'${ + lib.strings.escape [ "'" ] (toPlist { escape = true; } value) + }'"; + + defaultsToList = domain: attrs: + lib.mapAttrsToList (writeDefault domain) + (lib.filterAttrs (n: v: v != null) attrs); + cfg = config.defaults; - # Convert domain settings to defaults import command - domainToScript = domain: settings: - let - plistContent = toPlist { escape = true; } settings; - escapedDomain = lib.escapeShellArg domain; - in '' - $DRY_RUN_CMD echo "Applying defaults for ${domain}..." - $DRY_RUN_CMD /usr/bin/defaults import -app ${escapedDomain} - <<'EOF' - ${plistContent} - EOF - $DRY_RUN_CMD killall ${escapedDomain} && open -a ${escapedDomain} - ''; - - # Generate all activation scripts - activationScript = - lib.concatStringsSep "\n" (lib.mapAttrsToList domainToScript cfg); + # Generate all activation scripts by converting each domain's settings to defaults commands + activationScript = lib.concatStringsSep "\n" (lib.flatten + (lib.mapAttrsToList (domain: settings: defaultsToList domain settings) + cfg)); in { options.defaults = mkOption { From 33e7d70192e9846c61407c81bdf0bf10437b49b1 Mon Sep 17 00:00:00 2001 From: "Thomas A. Christensen II" <25492070+MillironX@users.noreply.github.com> Date: Mon, 3 Nov 2025 10:31:31 -0600 Subject: [PATCH 3/3] fix (Taskbar.app): use strings for config values For some reason, Taskbar.app stores all values as strings inside of it's plist. Rework the config to account for that. --- programs/taskbar.nix | 51 ++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/programs/taskbar.nix b/programs/taskbar.nix index 2906289..757d42d 100644 --- a/programs/taskbar.nix +++ b/programs/taskbar.nix @@ -1,53 +1,48 @@ { ... }: { defaults."Taskbar" = { - centerTasksAndButtons = 0; - hideReviewOptions = 1; - permissionsResetOnce = 1; - pinList = [ + eula1Accepted = "true"; + sendCrashReports = "true"; + showMenubarIcon = "false"; + updatePolicy = "2"; + pinList = builtins.toJSON [ { - action = "finderNewWindow"; - bundleIdentifier = "com.apple.finder"; - } - { - action = "launchOrActivateApp"; - bundleIdentifier = "com.apple.AppStore"; - } - { - action = "firefoxNewWindow"; - bundleIdentifier = "org.mozilla.firefox"; - } - { - action = "launchOrActivateApp"; bundleIdentifier = "com.apple.systempreferences"; + action = "launchOrActivateApp"; } { + bundleIdentifier = "com.apple.AppStore"; action = "launchOrActivateApp"; + } + { + bundleIdentifier = "com.apple.finder"; + action = "finderNewWindow"; + } + { + bundleIdentifier = "org.mozilla.firefox"; + action = "firefoxNewWindow"; + } + { bundleIdentifier = "org.mozilla.thunderbird"; - } - { action = "launchOrActivateApp"; - bundleIdentifier = "com.electron.logseq"; } { - action = "lauchOrActivateApp"; bundleIdentifier = "dev.zed.Zed"; + action = "launchOrActivateApp"; } { + bundleIdentifier = "com.electron.logseq"; action = "launchOrActivateApp"; + } + { bundleIdentifier = "com.apple.Safari.WebApp.2F51A6D0-087A-438F-92D3-A73FE09CB4CC"; + action = "launchOrActivateApp"; } { - action = "launchOrActivateApp"; bundleIdentifier = "com.apple.Safari.WebApp.5EC6478E-03A6-4147-8A4D-6EF3DE3F06D3"; + action = "launchOrActivateApp"; } ]; - sendCrashReports = 1; - showMenubarIcon = 0; - showThumbnails = 1; - showWindowTitleInThumbails = 1; - taskViewMaxWidth = 200; - updatePolicy = 2; }; }