Skip to content
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

Install app on macOS for neovide #319061

Merged
merged 1 commit into from
Jun 22, 2024
Merged

Conversation

triarius
Copy link
Contributor

@triarius triarius commented Jun 11, 2024

Description of changes

Produce .App for neovide on macOS environments.

Fixes: #301984

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.11 Release Notes (or backporting 23.11 and 24.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@NixOSInfra NixOSInfra added the 12. first-time contribution This PR is the author's first one; please be gentle! label Jun 11, 2024
@ofborg ofborg bot added the 6.topic: darwin Running or building packages on Darwin label Jun 11, 2024
@ofborg ofborg bot requested a review from ck3d June 11, 2024 14:01
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux labels Jun 11, 2024
@matteo-pacini matteo-pacini self-requested a review June 11, 2024 16:14
Copy link
Contributor

@matteo-pacini matteo-pacini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your first contribution, please check Contributing.md to get more insights on how to build a great PR!

Title suggestion: neovide: add darwin app
Commit message suggestion: neovide: add darwin app

The app does not run properly on aarch64-darwin - I would be expect it to be wrapped so neovim is added to its PATH?

EDIT: See @ck3d comment below about relying on neovim being present on user system

@triarius
Copy link
Contributor Author

Thanks for the informative comments @matteo-pacini. Looks I was a bit premature in making this PR. I thought it would work because I followed what was done in

if stdenv.isDarwin then ''
mkdir $out/Applications
cp -r extra/osx/Alacritty.app $out/Applications
ln -s $out/bin $out/Applications/Alacritty.app/Contents/MacOS
'' else ''
, and it did indeed work on my machine. I'll educate myself a bit, and hopefully I can fix this. Meanwhile, I'll mark this PR as a draft.

@triarius triarius marked this pull request as draft June 12, 2024 12:24
@triarius
Copy link
Contributor Author

Commit message suggestion: neovide: add darwin app

I assume it's acceptable to amend and force push to change the commit message? LMK what my alternative are otherwise.

@matteo-pacini
Copy link
Contributor

Commit message suggestion: neovide: add darwin app

I assume it's acceptable to amend and force push to change the commit message? LMK what my alternative are otherwise.

@triarius It is, ideally for this kind of update there should be two commits:

  • maintainer: add NAME
  • neovide: add darwin build (or platform, as long as it makes sense)

Something else to keep in mind when producing macOS apps derivations (happened to me recently with #318047 and #318535 ).

  • if you already have icons, no-codesigning to do, you're good to go

  • If you need to convert PNGs to icns, you can pull in libicns and use png2icons to create a icns bundle (+ imagemagick if you need to do resizing)

  • If you need codesigning (ad-hoc only I presume), you can pull in darwin.sigtool, that gives you an alternative codesign tool to do so

In your case, I think you only need to wrapProgram the final executable inside to app bundle so it can find the neovim executable.

@triarius triarius force-pushed the neovide-macos-app branch from 4c42657 to 4a0226a Compare June 12, 2024 22:27
@ofborg ofborg bot added 10.rebuild-linux: 1-10 10.rebuild-linux: 1 and removed 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux labels Jun 12, 2024
@@ -94,9 +94,14 @@ rustPlatform.buildRustPackage.override { stdenv = clangStdenv; } rec {

wrapProgram $out/bin/neovide \
--prefix LD_LIBRARY_PATH : ${libPath}
--prefix PATH : ${lib.makeBinPath [ neovim python3 ]}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neovide has no dependency to python3, please remove.
Neovide has a dependency to neovim, but we should rely on the user's environment. I think you increase the closure size of this package with no need. Further more, if the user installed in his environment, it would be ignored.

Copy link
Contributor Author

@triarius triarius Jun 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed them. I only put them in because it was not working for @matteo-pacini, presumably because there, it was run in an environment with no neovim install.

Copy link
Contributor Author

@triarius triarius Jun 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specifically, this:

The app does not run properly on aarch64-darwin - I would be expect it to be wrapped so neovim is added to its PATH?

But I see now that you both agree that it should use a neovim from the environment. So I've removed it.

postInstall = if stdenv.isDarwin then ''
mkdir -p $out/Applications
cp -r extra/osx/Neovide.app $out/Applications
ln -s $out/bin/.neovide-wrapped $out/Applications/Neovide.app/Contents/MacOS/neovide
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You created a wrapped neovide, but you use the unwrapped one, why?

Copy link
Contributor Author

@triarius triarius Jun 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My mistake, I misinterpreted this comment to mean I was not using the wrapped executable in the .app bundle. I then I thought .neovide-wrapped would be the wrapped one, as its name suggested. But I see now, by inspecting the neovide executable, that it's just a script that execs .neovim-wrapped. Hence, it is the wrapper for .neovide-wrapped.

@triarius triarius force-pushed the neovide-macos-app branch from 4a0226a to c095367 Compare June 17, 2024 13:38
@triarius triarius force-pushed the neovide-macos-app branch from 86bde81 to ded9632 Compare June 17, 2024 13:52
@ofborg ofborg bot requested a review from ck3d June 17, 2024 14:25
@ofborg ofborg bot added 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux and removed 10.rebuild-linux: 1 10.rebuild-linux: 1-10 labels Jun 17, 2024
@triarius triarius marked this pull request as ready for review June 17, 2024 21:10
@triarius triarius requested a review from matteo-pacini June 17, 2024 21:11
@ck3d ck3d merged commit 81aff3c into NixOS:master Jun 22, 2024
33 checks passed
@triarius triarius deleted the neovide-macos-app branch June 22, 2024 06:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: darwin Running or building packages on Darwin 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux 12. first-time contribution This PR is the author's first one; please be gentle!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Neovide on darwin does not produce an app bundle that can be linked to /Applications/Nix Apps
4 participants