-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Optional Mac-friendly functionality for nix-env
#1278
Comments
I think @matthewbauer's |
Related LnL7/nix-darwin#11. |
I think this is probably the right thing, though it's awful 👅 |
I don't think there should be any more Mac-specific features in Nix than is absolutely necessary. What I like about a Some important questions about this though:
|
Well, what I'm proposing wouldn't happen per-derivation. It'd be a post- I'd rather just make a "symlink tree" (alias tree) of the contents of the environment's |
Ok, that would definitely be simpler. Another thing to think about: how to go about cleaning up old Related is whether the |
@matthewbauer it should know the previous generation and the current generation and be able to figure out which aliases it should be getting rid of/changing/adding. The second point is what I didn't know in my original proposal, and also keep in mind that it can't be a symlink, but rather must be a Mac alias. |
We may want to do something like the |
Interesting, the only way to make these from a CLI seems to be osxutils? Somebody should get that in Nixpkgs😈... |
If there's interest in |
We could get font installation through Nix to work right on macOS this way, too, I think. :-) |
Is it enough to just tell LaunchServices about the application with |
@alyssais how do you mean? The main thing I was trying to address is that spotlight and spotlight-based tools (e.g., Alfred) for launching apps don't pick up symlinks, so even though we could symlink stuff to ~/Applications, they wouldn't be very user-friendly. Are you suggesting to put "fake" shim .apps into ~/Applications that then call the real ones in the nix store? |
@copumpkin FYI I realised the same thing (that spotlight and spotlight-based tools like Aflred) don't follow symlinks and did something like this using macOS Alias files ( This is not a general solution but you may be interested how I did it: And the swift code to create an alias file: https://github.com/eqyiel/dotfiles/blob/5fbad92e52a636bc85f10f06e7c0766009358038/nix/.config/nixpkgs/darwin/modules/link-apps/create-macos-alias.swift (Copying here for posterity because I set that repo to private) #!/usr/bin/env swift
// Create an alias file ("bookmark88" format). Note that although Finder treats
// this like a symlink, it is different.
//
// Equivalent to:
// osascript -e "tell application "Finder" to make new alias at POSIX file \"${dest}\" to POSIX file \"${src}\""
import Foundation
var src: String?
var dest: String?
if CommandLine.argc < 3 {
print("Expected two arguments: src and dest.")
exit(1)
} else {
src = CommandLine.arguments[1]
dest = CommandLine.arguments[2]
}
let url = URL(fileURLWithPath: src!)
let aliasUrl = URL(fileURLWithPath: dest!)
do {
let data = try url.bookmarkData(options: .suitableForBookmarkFile, includingResourceValuesForKeys: nil, relativeTo: nil)
try URL.writeBookmarkData(data, to: aliasUrl)
} catch {
print("Unexpected error: \(error).")
exit(1)
} |
I marked this as stale due to inactivity. → More info |
This is just an idea, but I'm trying to think of how I'd want .app files to be managed by Nix, and I think this is it:
$out/Applications/MyApp.app
nix-env
manages~/.nix-profile
on all systems, on Darwin it should be somewhat aware of~/Applications
Applications
in the profile's symlink tree, finds all top-level.app
files (really folders) in there, and creates/updates macOS alias files for them in~/Applications
. These need to be macOS aliases because Spotlight (the macOS indexing system) doesn't index symlinks. I'm unsure if the aliases need to point to the underlying nix store paths or if they can point to the symlinks in the user's profile. This isn't ideal because it hurts the atomicity of environment updates a bit, but I don't think it'll be terribleAny thoughts? It's not beautiful in part because
~/Applications
doesn't "belong" to Nix (so other things could be in it), and in part because we can't use symlinks, but I think it would work quite nicely for a lot of things.I see this as an alternate proposal to #956, which wants to completely own
~/Applications
and assumes symlinks.@edolstra @LnL7 @acowley @shlevy @domenkozar @mpscholten @matthewbauer
The text was updated successfully, but these errors were encountered: