Skip to content

Commit c48c010

Browse files
committed
feat(deps): add support for Nix package manager
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 SDKs, allowing us to run against macOS 11.x SDKs. This allows the resulting Emacs.app builds to be compatible with macOS 11.x and later versions. In testing, this seems to be the case on macOS 11.x (x86_64) and macOS 12.x (arm64).
1 parent 2758cc9 commit c48c010

File tree

17 files changed

+826
-184
lines changed

17 files changed

+826
-184
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ jobs:
88
runs-on: ubuntu-latest
99
steps:
1010
- uses: actions/checkout@v4
11-
- uses: actions/setup-go@v4
11+
- uses: actions/setup-go@v5
1212
with:
13-
go-version: "1.20"
13+
go-version: "1.23"
1414
- name: golangci-lint
15-
uses: golangci/golangci-lint-action@v3
15+
uses: golangci/golangci-lint-action@v6
1616
with:
17-
version: v1.55
17+
version: v1.61
1818
env:
1919
VERBOSE: "true"
2020

@@ -23,9 +23,9 @@ jobs:
2323
runs-on: ubuntu-latest
2424
steps:
2525
- uses: actions/checkout@v4
26-
- uses: actions/setup-go@v4
26+
- uses: actions/setup-go@v5
2727
with:
28-
go-version: "1.20"
28+
go-version: "1.23"
2929
- name: Check if mods are tidy
3030
run: make check-tidy
3131

@@ -34,9 +34,9 @@ jobs:
3434
runs-on: ubuntu-latest
3535
steps:
3636
- uses: actions/checkout@v4
37-
- uses: actions/setup-go@v4
37+
- uses: actions/setup-go@v5
3838
with:
39-
go-version: "1.20"
39+
go-version: "1.23"
4040
- name: Run tests
4141
run: make test
4242
env:

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
.DS_Store
22
.envrc
33
Formula/*
4-
Gemfile.lock
54
bin
65
builds
76
sources

.golangci.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ linters-settings:
77
gocyclo:
88
min-complexity: 20
99
govet:
10-
check-shadowing: true
1110
enable-all: true
1211
disable:
1312
- fieldalignment
@@ -23,9 +22,9 @@ linters:
2322
disable-all: true
2423
enable:
2524
- bodyclose
25+
- copyloopvar
2626
- dupl
2727
- errcheck
28-
- exportloopref
2928
- funlen
3029
- gochecknoinits
3130
- goconst
@@ -72,12 +71,12 @@ issues:
7271
- source: "`yaml:"
7372
linters:
7473
- lll
75-
76-
run:
77-
skip-dirs:
74+
exclude-dirs:
7875
- builds
7976
- sources
8077
- tarballs
78+
79+
run:
8180
timeout: 2m
8281
allow-parallel-runners: true
8382
modules-download-mode: readonly

Gemfile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,5 @@ source 'http://rubygems.org/'
55
gem 'ruby-macho'
66

77
group :development do
8-
gem 'byebug'
98
gem 'rubocop'
10-
gem 'rubocop-daemon'
11-
gem 'solargraph', '~> 0.39.17'
129
end

Gemfile.lock

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
GEM
2+
remote: http://rubygems.org/
3+
specs:
4+
ast (2.4.2)
5+
json (2.8.2)
6+
language_server-protocol (3.17.0.3)
7+
parallel (1.26.3)
8+
parser (3.3.6.0)
9+
ast (~> 2.4.1)
10+
racc
11+
racc (1.8.1)
12+
rainbow (3.1.1)
13+
regexp_parser (2.9.2)
14+
rubocop (1.68.0)
15+
json (~> 2.3)
16+
language_server-protocol (>= 3.17.0)
17+
parallel (~> 1.10)
18+
parser (>= 3.3.0.2)
19+
rainbow (>= 2.2.2, < 4.0)
20+
regexp_parser (>= 2.4, < 3.0)
21+
rubocop-ast (>= 1.32.2, < 2.0)
22+
ruby-progressbar (~> 1.7)
23+
unicode-display_width (>= 2.4.0, < 3.0)
24+
rubocop-ast (1.36.1)
25+
parser (>= 3.3.1.0)
26+
ruby-macho (4.1.0)
27+
ruby-progressbar (1.13.0)
28+
unicode-display_width (2.6.0)
29+
30+
PLATFORMS
31+
arm64-darwin
32+
ruby
33+
x86_64-darwin
34+
35+
DEPENDENCIES
36+
rubocop
37+
ruby-macho
38+
39+
BUNDLED WITH
40+
2.5.23

Makefile

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ bootstrap-ruby:
5151
bundle install
5252

5353
bootstrap-brew:
54+
ifndef IN_NIX_SHELL
5455
brew bundle --verbose
56+
endif
5557

5658
bootstrap-pip:
5759
$(PIP) install -r requirements-ci.txt
@@ -69,7 +71,7 @@ $(TOOLDIR)/$(1): Makefile
6971
endef
7072

7173
$(eval $(call tool,gofumpt,mvdan.cc/gofumpt@latest))
72-
$(eval $(call tool,golangci-lint,github.com/golangci/golangci-lint/cmd/golangci-lint@v1.55))
74+
$(eval $(call tool,golangci-lint,github.com/golangci/golangci-lint/cmd/golangci-lint@v1.61))
7375
$(eval $(call tool,gomod,github.com/Helcaraxan/gomod@latest))
7476

7577
.PHONY: tools
@@ -132,6 +134,21 @@ format: $(TOOLDIR)/gofumpt
132134
gen:
133135
go generate $$(go list ./... | grep -v 'sources/' | grep -v 'builds/')
134136

137+
.PHONY: nix-flake-update
138+
nix-flake-update:
139+
nix flake update \
140+
&& $(MAKE) flake-package-versions.txt
141+
142+
.SILENT: flake-package-versions
143+
flake-package-versions:
144+
nix develop --command -- bash -c \
145+
'nix derivation show \
146+
$$(echo $$PATH | tr ":" "\n" | grep "/nix/store" | sort -u) \
147+
| jq -r ".[].name" | sort -u'
148+
149+
flake-package-versions.txt: flake.nix flake.lock
150+
$(MAKE) flake-package-versions > flake-package-versions.txt
151+
135152
#
136153
# Dependencies
137154
#

README.md

Lines changed: 55 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,40 @@ The build produced does have some limitations:
3636

3737
## Requirements
3838

39+
Required with both Nix and Homebrew approaches:
40+
3941
- [Xcode](https://apps.apple.com/gb/app/xcode/id497799835?mt=12)
40-
- [Homebrew](https://brew.sh/)
41-
- Ruby 2.3.0 or later is needed to execute the build script itself. macOS comes
42-
with Ruby, check your version with `ruby --version`. If it's too old, you can
43-
install a newer version with:
44-
```
45-
brew install ruby
46-
```
47-
- All dependencies can all easily be installed by running:
48-
```
49-
make bootstrap
50-
```
42+
43+
### Nix
44+
45+
The [Nix](https://nixos.org/) package manager is the preferred and most reliable
46+
way to install all dependencies required to build Emacs, by way of a Nix flake
47+
included in the project root.
48+
49+
To install all required dependencies within the nix shell, run:
50+
51+
```
52+
nix develop --command make bootstrap
53+
```
54+
55+
### Homebrew
56+
57+
If you do not have Nix installed, then the alternative way to manage and install
58+
build-time dependencies is via [Homebrew](https://brew.sh/).
59+
60+
Ruby 3.3.x or later is also needed to execute the build script. Earlier versions
61+
may work, but are untested. Simplest way to install a recent Ruby version is via
62+
Homebrew:
63+
64+
```
65+
brew install ruby
66+
```
67+
68+
And finally, to install all built-time dependencies, run:
69+
70+
```
71+
make bootstrap
72+
```
5173

5274
## Status
5375

@@ -71,17 +93,38 @@ Nightly builds are built with GitHub Actions on GitHub-hosted runners, using
7193

7294
## Usage
7395

96+
### Nix
97+
98+
Ensure [Flakes](https://nixos.wiki/wiki/Flakes) are enabled, and enter the flake
99+
development environment with `nix develop`. Within this environment, you can
100+
execute the `./build-emacs-for-macos --help` to get started.
101+
102+
Or you can run the build script via `nix develop`:
103+
104+
```
105+
nix develop --command ./build-emacs-for-macos --help
106+
```
107+
108+
### Homebrew
109+
110+
Run `make boostrap` to ensure all Ruby and Homebrew dependencies are installed.
111+
112+
### Build Script
113+
74114
```
75115
Usage: ./build-emacs-for-macos [options] <branch/tag/sha>
76116
77117
Branch, tag, and SHA are from the emacs-mirror/emacs/emacs Github repo,
78118
available here: https://github.com/emacs-mirror/emacs
79119
80120
Options:
121+
--info Print environment info and detected library paths, then exit
122+
--preview Print preview details about build and exit.
81123
-j, --parallel COUNT Compile using COUNT parallel processes (detected: 16)
82124
--git-sha SHA Override detected git SHA of specified branch allowing builds of old commits
125+
--[no-]use-nix Use Nix instead of Homebrew to find dependencies (default: enabled if EMACS_BUILD_USE_NIX is set to truthy value)
83126
--[no-]xwidgets Enable/disable XWidgets if supported (default: enabled)
84-
--[no-]tree-sitter Enable/disable tree-sitter if supported (default: enabled)
127+
--[no-]tree-sitter Enable/disable tree-sitter if supported(default: enabled)
85128
--[no-]native-comp Enable/disable native-comp (default: enabled if supported)
86129
--[no-]native-march Enable/disable -march=native CFLAG(default: disabled)
87130
--[no-]native-full-aot Enable/disable NATIVE_FULL_AOT / Ahead of Time compilation (default: disabled)

0 commit comments

Comments
 (0)