Open mknudsen opened 1 month ago
There are multiple problems with the way macOS applications are added to the /Applications
directory right now.
Because symlinks aren't supported by Spotlight, it is unable to index Nix applications properly without a "trampoline" application located outside of /Applications/Nix Apps
. ("You can’t open the application Zoom.app because it may be damaged or incomplete.")
The macOS dock needs to be updated on any update of the application due to its path changing in the Nix store.
Although something like mac-app-util is able to both generate a trampoline application and update the macOS dock upon performing a system switch, this sometimes results in two application icons in the dock when the application is open: one for the trampoline, the other for the "target" app inside Nix Apps
.
Applications started through the Finder at /Applications/Nix Apps
appear as a single command name, without application icon, inside the macOS privacy settings. They also remain referenced there after their deletion.
The thread at https://github.com/NixOS/nix/issues/7055 is very informative, and proposes an interesting solution which leverages filesystem aliases instead of symlinks: https://github.com/NixOS/nix/issues/7055#issuecomment-1250166187
Aliases also have significant issues; see https://github.com/nix-community/home-manager/issues/1341 for discussion. Probably copying is the best solution. That’s what Homebrew settled on eventually too.
@emilazy are you referring to these two points?
Aliases won't be categorized under "Applications" [by Spotlight]
Aliases are kind of awful to work with - you can't seem to create them from the CLI without pinging finder via AppleScript / osascript
Yes, though also making aliases through Finder is a hack with its own set of problems so we’d want to use a native code solution to accomplish it even if we went that route. The Spotlight problem is pretty serious though. If there was something other than copying that worked well I expect Homebrew Cask would have already adopted it.
Aliases can be created programatically (e.g., https://github.com/reckenrode/mkalias). Finder should not be scripted. It undermines TCC. macOS 15 also requires explicit approve Finder of scripting in Security & Privacy, making the experience even worse (probably to discourage scripting of Finder because it’s effectively equivalent to having Full Disk Access).
(I’m also pretty sure aliases share similar limitations to the trampoline method with references to the store in the dock and services not being available until an aliased application has been launched, but it’s been so long since I looked into it that I don’t remember for sure.)
Is your concern simply finding them in spotlight?
Is your concern simply finding them in spotlight?
Yes, cmd + space happens to be the way I start most my apps.
Same goes for Alfred, can't find it if it isn't in Applications.
Raycast shows my nix-darwin (/Applications/Nix Apps
) and home-manager (~/Applications/Home Manager Apps
) apps correctly 👍
Is your concern simply finding them in spotlight?
Yes, cmd + space happens to be the way I start most my apps.
There are a few ways to accomplish this, at least of which I am aware, but each has a downside or limitation. The best option is to create a symlink in your Applications
that will have all installed applications, cli tools, etc. appear as Other
.
Try entering this block into your configuration:
in
pkgs.lib.mkForce ''
# Set up applications.
echo "setting up /Applications..." >&2
rm -rf /Applications/Nix\ Apps
mkdir -p /Applications/Nix\ Apps
find ${env}/Applications -maxdepth 1 -type l -exec readlink '{}' + |
while read src; do
app_name=$(basename "$src")
echo "copying $src" >&2
${pkgs.mkalias}/bin/mkalias "$src" "/Applications/Nix Apps/$app_name"
done
find ${env}/Applications -maxdepth 1 -type l -exec readlink '{}' + |
'';
so for me, it works for most home-manager packages. (except discord for some reason) While for systempackages it does not work at all.
I have a bunch of apps installed through nix-darwin and I can launch them from command line, i.e. Zoom with
zoom
.I also see them in
/run/current-system/Applications/
. I however cannot find them through finder. How do I make macOS aware or those apps?darwin-rebuild check
tells me everything is ok.Here are my software versions