···99 ../../modules/darwin/packages.nix
1010 ../../modules/darwin/homebrew.nix
1111 ../../modules/darwin/system.nix
1212+ ../../modules/darwin/launch-services.nix
1213 ];
13141415 # Primary user for homebrew and user-specific options
+31
modules/darwin/launch-services.nix
···11+{ config, lib, pkgs, ... }:
22+33+##############################################################################
44+# Launch Services Management for macOS
55+#
66+# Automatically rebuilds the Launch Services database after system activation
77+# to ensure Nix-installed applications are properly registered with macOS.
88+#
99+# This solves issues where apps show "can't be opened" errors because
1010+# macOS doesn't recognize apps from the Nix store or symlinked locations.
1111+##############################################################################
1212+1313+{
1414+ system.activationScripts.postActivation.text = lib.mkAfter ''
1515+ echo "Rebuilding Launch Services database..." >&2
1616+1717+ # Clear and rebuild the Launch Services database
1818+ # This ensures all Nix apps are properly registered with macOS
1919+ /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister \
2020+ -kill -r -domain local -domain system -domain user
2121+2222+ # Reset Launchpad cache to show updated apps
2323+ # This is necessary for apps to appear in Spotlight and Launchpad
2424+ find 2>/dev/null /private/var/folders/ -type d -name com.apple.dock.launchpad -exec rm -rf {} + || true
2525+2626+ # Restart Dock to apply changes
2727+ killall Dock || true
2828+2929+ echo "Launch Services database rebuilt successfully" >&2
3030+ '';
3131+}