-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide a convention for allowing MacOS Spotlight to index Applications without getting hacky #7055
Comments
AIUI, we're between a rock and a hard place here. First up are the things people tend to want:
And then there's what the Apple gives us:
I know some people in the macOS channel on Matrix have been experimenting with trying to find ways around, but (from the sidelines) it's sounded like they all have problems of their own. Barring discovery of good options that I don't yet know about, I suspect our best bets are:
|
Really appreciate that thorough response. Part of my thinking in raising this issue was that it was fairly time consuming for me to collect enough info on this issue to find a way forward. Just by having this GitHub issue up with an option might alone be enough to provide some value to people who, like me, get stuck on this. And what do you think about these other possible responses to this issue?
Option 1 doesn't fix the real problem, but will hopefully save people an 30+ minutes of digging. Option 2 feel like a bit of a long shot. I don't have the insight into Nix to know if it is a crazy suggestion or not (but at least if it is a new option then it would be a backwards compatible change). |
I'm not really responding as a decider here, just as someone who had to wrestle with some of these details while doing some installer work. This might get more interesting with feedback from more of the people who've looked into this, so I've posted it in chat. This (managing stateful non-Nix directories on the host system tends) also falls in a bit of a roll-off between what tends to get treated as Nix's responsibility and what tends to get left up to other tools. I'm not sure if a true fix within Nix itself would be seen as in-scope, but in any case I suspect it won't make a ton of sense to try to address this at that level until the attempts to address it (I think just for ~/Applications?) within |
There's a lot of discussion about this in the context of nix-community/home-manager#1341 and LnL7/nix-darwin#214. I think the home-manager thread arrives at a good solution, and I've got a not-too-hacky version in home.nix to tide me over until changes land: home.activation = {
# This should be removed once
# https://github.com/nix-community/home-manager/issues/1341 is closed.
aliasApplications = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
app_folder="$(echo ~/Applications)/Home Manager Apps"
home_manager_app_folder="$genProfilePath/home-path/Applications"
$DRY_RUN_CMD rm -rf "$app_folder"
# NB: aliasing ".../home-path/Applications" to "~/Applications/Home Manager Apps" doesn't
# work (presumably because the individual apps are symlinked in that directory, not
# aliased). So this makes "Home Manager Apps" a normal directory and then aliases each
# application into there directly from its location in the nix store.
$DRY_RUN_CMD mkdir "$app_folder"
for app in $(find "$newGenPath/home-path/Applications" -type l -exec readlink -f {} \;)
do
$DRY_RUN_CMD osascript \
-e "tell app \"Finder\"" \
-e "make new alias file at POSIX file \"$app_folder\" to POSIX file \"$app\"" \
-e "set name of result to \"$(basename $app)\"" \
-e "end tell"
done
'';
}; |
FWIW, I've found that the cleanest way to do this is to just delete/copy the application in the activation script. It just takes 3 lines and has never caused problems for me. Example (unsure if the chmod is still necessary, it was at some point):
|
If we were able to do that generically, eg via |
Reverts commit 8f92fa5 Reverts commit 076b9af It has been a fun and educational experiment, but the hacky nature of this installation outweighs the benefit of having WezTerm.app managed by Nix: - Spotlight is unable to index the application properly without a "trampoline" application located outside of '/Applications/Nix Apps'. ("You can’t open the application WezTerm.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 mac-app-util is able to both generate the trampoline application and update the macOS dock upon performing a system switch, this results in two WezTerm application icons in the dock when the application is open: one for the trampoline, the other for wezterm-gui. - WezTerm appears as 'wezterm-gui' and without application icon inside the macOS privacy settings. - Finally, because the trampoline application opens WezTerm indirectly, the shell's SHLVL starts with 2 in Zsh, which shows in the prompt and is distracting. Related Nix issue: NixOS/nix#7055
Describe the bug
I am trying to use
nix-env
to install applications like Alacritty and others that come with a.app
file, but Spotlight won't work without manual changes to configuration post-install of nix. To integrate this with MacOS, I am usingstow
to create a symlink for that.app
file in my/Applications
directory. This alias can be clicked directly or added to the dock without issue, but Spotlight will not index those symlinked files.I am aware that there was a change to explicitly prevent indexing of the
/nix
directory, some documentation being added here: #5730. After a bit more digging I found that I could remove thatnobrowse
option and found that after dropping it and restarting my computer the applications were indexed. While I have a solution, I don't really like it. It is brittle and opaque. I think other people will also want to do something similar on MacOS, so have a conventional solution seems appropriate.Steps To Reproduce
nix-env -iA nixpkgs.alacritty
.stow -d "$(nix-env -q --installed alacritty --out-path --no-name)" -t /Applications Applications.
mdfind alacritty
does not find the executable app.sudo vifs
and removenobrowse
for/nix
.mdfind alacritty
turns up results.Expected behavior
Now, I'm very new to Nix and there is a lot to digest, so I might have missed this, but what I'd hope to have seen is something in the manual or other docs that gives instructions on a standard Nix solution for installing apps in MacOS that are properly integrated like traditionally installed applications, i.e. can be found in
/Applications
and searched for with Spotlight. It would also be ideal if the fix does not require manually modifying a file post-install of nix.nix-env --version
outputnix-env (Nix) 2.11.1
Additional context
I have being going on a deep dive of this tool for a couple days and am really excited about it. Awesome work and thanks so much <3
The text was updated successfully, but these errors were encountered: