cmacrae / emacs

Nightly custom Emacs builds for macOS Nix environments
MIT License
40 stars 17 forks source link

Support M1 machines #3

Closed cmacrae closed 2 years ago

choco commented 2 years ago

Any timeline for this? I'm a nix and emacs newbie, but maybe I can help either way

cmacrae commented 2 years ago

I don't own an M1 machine yet, I'm afraid. I believe GitHub aren't providing hosts for Apple silicon just yet, which I would have to rely on without owning one (not going to try even going near cross compilation for this 😅).

So, until I own an M1 machine, I likely won't be adding support for it.
In theory, it should be fairly trivial to add - I just don't want to blindly add what I think should work without being able to build and test :)

antifuchs commented 2 years ago

When I still had my M1 machine (had to exchange it for an intel for work), I was using this repo's overlay in my nix-darwin aarch64-darwin configuration (following the instructions in https://github.com/LnL7/nix-darwin/issues/334). I didn't realize that this might not be supposed to work, but I suspect it ... just did?

phaer commented 2 years ago

@antifuchs If it worked without any changes from the flake, your probably built and ran an x86_64 binary on your M1 via rosetta. It's pretty impressive to me how transparent that emulation can be.

Anyways, I opened up a pull request #5 to allow native builds for M1. The resulting binary works on my new Macbook Pro 2021, but other tests would be appreciated. Maybe @choco wants to help?

choco commented 2 years ago

Hey guys, since GitHub doesn't provide arm64 macOS build machines right now I'm just using my own overlay (on top of emacs-overlay) which looks like this:

emacs = (prev.emacsGit.override { withXwidgets = true; nativeComp = true; }).overrideAttrs (old: {
  buildInputs = old.buildInputs ++ [ prev.darwin.apple_sdk.frameworks.WebKit ];
  patches = old.patches ++ [
    ../patches/emacs-no-titlebar.patch
    ../patches/emacs-fix-window-role.patch
    ../patches/emacs-fix-thin-smoothing.patch
    ../patches/emacs-no-frame-refocus.patch
    ../patches/emacs-system-appearance.patch
  ];
  postInstall = old.postInstall + ''
   cp ${../patches/emacs-rounded-square-icon.icns} $out/Applications/Emacs.app/Contents/Resources/Emacs.icns
  '';
});

It's basically latest emacs git version with xwidgets and gcc native compilation, plus a bunch of patches (mostly from the https://github.com/d12frosted/homebrew-emacs-plus repo) plus a fix for the font smoothing setting that is broken since macOS big sur. I also change the icon to another that I like better. For the vterm module you can then wrap the above in (emacsPackagesFor emacs) or let emacs just install it themselves (both worked for me)

cmacrae commented 2 years ago

Considering this fixed for now with @phaer's contributions in #5 🙇