-
-
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
Automatically link macOS applications to ~/Applications #956
Comments
Maybe this could be supported by nix-env, running a hook script placed under the nix-support folder. |
Great suggestion :) Is there already a simple hook system in nix-env? Otherwise I'd try to build a very simple prototype for this in the next days. |
I can't see any such system in nix-env. I think it should be safe to make one as long as the system can be disabled. |
Can't you:
|
On the next |
Just FYI guys, this is far more complicated than you might expect and I would strongly suggest reading that thread and all the links in it in their entirety before making a change like this. |
So I've been using a script to do this available here: https://raw.githubusercontent.com/matthewbauer/macNixOS/master/link-apps.sh. ProposalAdd Users specify a script or executable to run after nix has successfully completed "createUserEnv", meaning that software installed by nix-env has been successfully added to the user profile. This script could look through This hook is designed for non-NixOS systems that need to do some extra things after the This should be fairly easy to implement. It would work similarly configuration-wise to the "preBuildHook". The actual script execution would probably be done immediately after line 148 in src/nix-env/user-env.cc. |
Great suggestion. If it's easier to implement we could also just hard code the hook for now (so the user cannot change the hook). Then it just would be something like Just got the idea for another very cool use case: We could also use the hook to automatically create Also thanks for sharing your script. I was already using a similar script, but it was never removing the old dead symlinks. Going to replace my script with yours 👍 |
I think that would be better as just an install step - there's no reason to rerun that each time it regenerates the profile. We can set /etc/paths.d/nix to /nix/var/profiles/default in a custom installer. |
Any updates? |
I marked this as stale due to inactivity. → More info |
I am also interested in a way to do this. Are there any updates? The linked issues also seem to be unresolved/stale. |
There is a solution at the bottom of this: nix-community/home-manager#1341 |
Thanks @Atemu, I have a newbie question : how to use your solution in practice? I'm not using home-manager yet, and I'm totally new to Nix. |
@MorganGeek just add the file to your |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/mac-applications-installed-by-nix-are-not-loaded-by-spotlight/14129/1 |
I marked this as stale due to inactivity. → More info |
This issue is still relevant. I would love to stop using Homebrew, but currently still use it for installing casks/macOS applications. |
I think the general problem can and should be addressed by external tools wrapping Nix, such as done here with @edolstra @domenkozar objections to closing this issue? |
If anything, I would advise aliases rather than symlinks. Spotlight picks up aliases. I use something like this (warning: untested): # Install all nix top level graphical apps
if [[ -d ~/.nix-profile/Applications ]]; then
(cd ~/.nix-profile/Applications;
for f in *.app ; do
mkdir -p ~/Applications/
rm -f "$HOME/Applications/$f"
# Mac aliases don’t work on symlinks
f="$(readlink -f "$f")"
# Use Mac aliases because Spotlight doesn’t like symlinks
osascript -e "tell app \"Finder\" to make new alias file at POSIX file \"$HOME/Applications\" to POSIX file \"$f\"" ; done
done
)
fi That being said: it's not without drawbacks. If possible, it's strongly advised to find a way to cp -r the entire .app folder, as homebrew does. Homebrew used to use links, and eventually changed course. I do use an alias for Emacs.app though, and it's fine. The nixpkgs build of emacs breaks when you cp it to ~/Applications :/ (but that's a bug report for another time)
|
Discussed in Nix team meeting 2023-01-06:
|
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2023-01-06-nix-team-meeting-minutes-21/24573/1 |
@fricklerhandwerk The issue was moved here from the Nixpkgs repo with the rationale that Nixpkgs doesn't have enough write permissions and that it's very similar to managing ~/.nix-profile So where should it go from here, you think? Not every Nix user under macOS uses nix-darwin, so probably home-manager? |
Either should do in principle. But conversely one can use nix-darwin without Home Manager, so probably both have to support that. |
(previously: NixOS/nixpkgs#16455)
Currently, when installing macOS GUI applications like iTerm2 or Sequel Pro, you always have to manually symlink the applications from
~/.nix-profile/Applications
to~/Applications
. This is bad user experience. E.g. homebrew cask can automatically do this for me.Maybe we can find a way to do this automatically if the host OS is macOS. Let me know what you think about this idea :)
The text was updated successfully, but these errors were encountered: