Skip to content

Commit

Permalink
feat(deps): add support for Nix package manager
Browse files Browse the repository at this point in the history
This serves as an alternative to Homebrew. It should be much more stable
and cause less headaches over time for automated builds.

There should be no change to the end user experience of using the build
script, as it should still work with and use Homebrew by default.

Additionally, Nix provides older Apple SDK's, so builds run against
macOS 11.x SDKs via Nix. This should in theory allow the resulting
Emacs.app builds should be compatible with older macOS versions. Exactly
how well that holds up in practice remains to be seen.

Nix does support customizing the Apple SDK version, but I have not yet
figured out how to do so via a flake, and it's not a priority at the
moment, as the default v11 SDK is sufficient.
  • Loading branch information
jimeh committed Nov 3, 2024
1 parent 970cb68 commit 021845a
Show file tree
Hide file tree
Showing 6 changed files with 581 additions and 142 deletions.
35 changes: 34 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ The build produced does have some limitations:
## Requirements

- [Xcode](https://apps.apple.com/gb/app/xcode/id497799835?mt=12)

# Nix

The [Nix](https://nixos.org/) package manager is the preferred and most reliable
way to install all dependencies required to build Emacs. Alternatively you can
also use Homebrew.

### Homebrew

If you do not have Nix installed, then the alternative way to manage and install
all dependencies is via Homebrew.

- [Homebrew](https://brew.sh/)
- Ruby 2.3.0 or later is needed to execute the build script itself. macOS comes
with Ruby, check your version with `ruby --version`. If it's too old, you can
Expand Down Expand Up @@ -71,17 +83,38 @@ Nightly builds are built with GitHub Actions on GitHub-hosted runners, using

## Usage

### Nix

Ensure [Flakes](https://nixos.wiki/wiki/Flakes) are enabled, and enter the flake
development environment with `nix develop`. Within this environment, you can
execute the `./build-emacs-for-macos --help` to get started.

Or you can run the build script via `nix develop`:

```
nix develop --command ./build-emacs-for-macos --help
```

### Homebrew

Run `make boostrap` to ensure all Ruby and Homebrew dependencies are installed.

### Build Script

```
Usage: ./build-emacs-for-macos [options] <branch/tag/sha>
Branch, tag, and SHA are from the emacs-mirror/emacs/emacs Github repo,
available here: https://github.com/emacs-mirror/emacs
Options:
--info Print environment info and detected library paths, then exit
--preview Print preview details about build and exit.
-j, --parallel COUNT Compile using COUNT parallel processes (detected: 16)
--git-sha SHA Override detected git SHA of specified branch allowing builds of old commits
--[no-]use-nix Use Nix instead of Homebrew to find dependencies (default: enabled if EMACS_BUILD_USE_NIX is set to truthy value)
--[no-]xwidgets Enable/disable XWidgets if supported (default: enabled)
--[no-]tree-sitter Enable/disable tree-sitter if supported (default: enabled)
--[no-]tree-sitter Enable/disable tree-sitter if supported(default: enabled)
--[no-]native-comp Enable/disable native-comp (default: enabled if supported)
--[no-]native-march Enable/disable -march=native CFLAG(default: disabled)
--[no-]native-full-aot Enable/disable NATIVE_FULL_AOT / Ahead of Time compilation (default: disabled)
Expand Down
Loading

0 comments on commit 021845a

Please sign in to comment.