-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathelisp-packages.nix
341 lines (338 loc) · 13.2 KB
/
elisp-packages.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
{
emacs,
eself,
esuper,
git,
lib,
makeWrapper,
stdenvNoCC,
writeText,
}:
{
# Doom uses emacs-straight/auctex, which still contains parts of upstream's
# build system but does not contain all .in files, resulting in a failed build
# if we attempt to use upstream's configure.
#
# Use melpaBuild instead of trivialBuild because company-auctex installs as a
# package (with a specified dependency) while trivialBuild does not include
# the necessary package metadata to satisfy that dependency.
auctex = esuper.melpaBuild {
pname = "auctex";
version = "1";
meta = {
description = "build auctex from emacs-straight for Doom";
};
# Most of auctex fails to byte-compile unless we do this.
# TODO: figure out why this is necessary (there may be a better
# solution).
preBuild = ''
mkdir home
export HOME="$PWD/home"
'';
# TODO: set this properly (melpa2nix requires it).
commit = "unset";
recipe = writeText "auctex-recipe" ''
(auctex :fetcher github :repo "emacsmirror/auctex")
'';
};
# Doom lets Straight provide org-autoloads.el as an alternative for
# org-loaddefs.el, and manually generates org-version.el.
#
# I currently run Org's build system to generate org-version.el.
# But we need this org on load-path while byte-compiling packages that depend on it.
# We accomplish that by using a melpaBuild for everything else.
#
# If we let org install itself, it ends up in an "org" subdir of site-lisp that is not on
# load-path while byte-compiling dependent packages, causing those to pick up the built-in version
# of org (causing problems at runtime).
#
# This ends up writing both org-autoloads.el and org-loaddefs.el, which combined provide the same
# autoloads org-loaddefs.el has when using just Org's build system. I doubt all this is working as
# intended, but the end result seems to work...
org = esuper.melpaBuild {
pname = "org";
version = "1";
meta = {
description = "build org-mode from emacs-straight repo for Doom";
};
buildInputs = [ ];
nativeBuildInputs = [
emacs
makeWrapper
];
# Finding ORGVERSION is a hack (based on the one in Doom).
# TODO: set GITVERSION?
# datadir makes oc-csl find etc/csl and ox-odt find etc/styles.
# org-odt-schema-dir stays nil because it looks for od-schema*.rnc which is not installed.
# (Not sure if OpenDocument-schema-v1.3.rnc is misnamed or this file is not distributed...)
configurePhase = ''
echo "prefix = $out" > local.mk
echo "datadir = $out/share/emacs/site-lisp/org/etc" >> local.mk
echo "ORGVERSION = $(sed -ne 's/^;; Version: \([^\n-]\+\).*/\1/p' lisp/org.el)" >> local.mk
make config
'';
preBuild = ''
make autoloads
'';
postInstall = ''
make install-etc install-info
'';
};
org-contrib = esuper.melpaBuild {
pname = "org-contrib";
version = "1";
meta = {
description = "build org-contrib from emacsmirror for Doom";
};
packageRequires = [ eself.org ];
};
sln-mode = esuper.melpaBuild {
pname = "sln-mode";
version = "1";
meta = {
description = "build sln-mode for doom with manual dependencies";
};
# Straight uses a recipe from el-get that specifies the font-lock-ext
# dependency.
buildInputs = [ eself.font-lock-ext ];
};
# Straight checks for git's presence at import time.
# We could probably get by with feeding it /bin/true or similar,
# but it seems not worth the risk.
straight = esuper.melpaBuild {
pname = "straight";
version = "1";
meta = {
description = "build straight with Git dependency added for Doom";
};
# Do not install files that shadow builtins and/or have undesirable side
# effects if loaded.
files = "(\"straight*.el\")";
nativeBuildInputs = [ git ];
};
# Nix uses a Melpa recipe that assumes the upstream CMake repo layout.
# Doom uses emacsmirror and sets :files (:defaults "*").
cmake-mode = esuper.melpaBuild {
pname = "cmake-mode";
version = "1";
meta = {
description = "build cmake-mode from emacsmirror for Doom";
};
};
# Doom uses a recipe with :files (:defaults "*"), which MELPA's package-build
# rejects because it includes dotfiles
# (https://github.com/melpa/package-build/pull/67).
# Use a melpaBuild here so the package ends up in its own directory:
# it uses that directory as a snippets directory, and using site-lisp/ as that
# might go wrong.
doom-snippets = esuper.melpaBuild {
pname = "doom-snippets";
version = "1";
# melpa2nix requires that we set this. TODO: set correctly.
commit = "unset";
meta = {
description = "trivial build of doom-snippets";
};
# The directories we want to match must be mode names: assume those are
# sensibly named (they currently are).
recipe = writeText "doom-snippets-recipe" ''
(doom-snippets :fetcher github :repo "doomemacs/snippets"
:files (:defaults "*-mode"))
'';
packageRequires = [ eself.yasnippet ];
# Stop all snippets from ending up on load-path via
# normal-top-level-add-subdirs-to-load-path.
# Avoids "default" in one of these from being mistaken for default.el.
preBuild = ''
for d in *-mode; do
touch $d/.nosearch
done
'';
};
# Contains an extension containing debug.el that should not be on load-path.
julia-snail = esuper.julia-snail.overrideAttrs (old: {
preBuild =
(old.preBuild or "")
+ ''
for d in extensions/*; do
touch $d/.nosearch
done
'';
});
# TODO: refactor our dependency-extraction so we can apply it selectively to packages we don't
# generate the entire derivation for.
#
# TODO: remove this once Doom catches up.
#
# Upstream dropped the haskell-mode dependency
# (https://github.com/emacs-lsp/lsp-haskell/commit/f5214c6146b3163e83c0b03d27d1222cc319e1fd),
# and emacs-overlay picked that up, but we're pinned to a revision where the code still has the
# dependency. Force it back in for now.
lsp-haskell = esuper.lsp-haskell.overrideAttrs (old: {
packageRequires = old.packageRequires ++ [ eself.haskell-mode ];
});
# Same problem: upstream dropped the dash dependency, but the version we're pinned to needs it.
magit-section = esuper.magit-section.overrideAttrs (old: {
packageRequires = old.packageRequires ++ [ eself.dash ];
});
tree-sitter-langs =
# Normally (outside nixpkgs), this package's tree-sitter-langs-build pulls a pre-compiled
# grammar bundle from github. It also contains a build system to build that bundle from
# submodules.
#
# Normally (inside nixpkgs), nixpkgs substitutes its own bundle for upstream's. It puts
# upstream's version number (from melpa stable) in that bundle, which tree-sitter-langs compares
# against its version number hardcoded as tree-sitter-langs--bundle-version.
#
# If Doom pins this package (which it does), that affects tree-sitter-langs--bundle-version but
# not the version in the grammar bundle nixpkgs created. This causes tree-sitter-langs-build to
# attempt to download its bundle and overwrite the nixpkgs one. This fails (with a download
# error at build time and an attempt to write into the Nix store at runtime).
#
# Since the bundle version already does not match upstream's version anyway, take the easy way
# out: patch that version number to match what nixpkgs put in the grammar bundle.
let
inherit (esuper.melpaStablePackages.tree-sitter-langs) version;
in
esuper.tree-sitter-langs.overrideAttrs (old: {
postPatch =
old.postPatch or ""
+ ''
sed -i -e '/defconst tree-sitter-langs--bundle-version/ s/"[0-9.]*"/"${version}"/' \
./tree-sitter-langs-build.el
'';
});
# Fix /build/ leaking into byte-compiled files (patch accepted upstream).
phpactor = esuper.phpactor.overrideAttrs (attrs: {
patches = (attrs.patches or [ ]) ++ [
./elisp-patches/0001-Do-not-call-locate-user-emacs-file-when-compiling.patch
];
});
# https://github.com/emacs-taskrunner/helm-taskrunner/issues/2
# TODO: make our generated melpaBuild available in esuper?
# (upstream unchanged for 5 years, not urgent to make this robust...)
helm-taskrunner = esuper.melpaBuild {
pname = "helm-taskrunner";
version = "9999snapshot";
commit = "unset";
meta = {
description = "trivial build for doom-emacs";
};
packageRequires = [
eself.projectile
eself.helm
];
recipe = writeText "auctex-recipe" ''
(helm-taskrunner :fetcher github :repo "emacs-taskrunner/helm-taskrunner")
'';
patches = [
./elisp-patches/helm-taskrunner-version.patch
];
};
# mu4e-compat depends on mu4e, which (if I understand correctly) cannot be on melpa because it is
# bundled with mu, and therefore mu4e-compat cannot have the dependency in its package-requires.
# But it does not byte-compile without mu4e present. Add the dependency.
mu4e-compat = esuper.melpaBuild {
pname = "mu4e-compat";
version = "9999snapshot";
commit = "unset";
meta = {
description = "trivial build for doom-emacs";
};
packageRequires = [ eself.mu4e ];
recipe = writeText "mu4e-recipe" ''
(mu4e-compat :fetcher github :repo "tecosaur/mu4e-compat")
'';
};
# TODO: attempt to fix sly-stepper properly.
# sly-stepper `require`s `sly-stickers`. That lives in sly's contribs subdirectory: it looks like
# that is normally added to the load path by `sly-setup`, which Doom runs from after-init-hook.
# But at byte compile time that subdirectory is not on the load path, breaking byte compilation.
sly-stepper = esuper.melpaBuild {
pname = "sly-stepper";
version = "9999snapshot";
commit = "unset";
meta = {
description = "trivial build for doom-emacs";
};
packageRequires = [ eself.sly ];
recipe = writeText "sly-stepper-recipe" ''
(sly-stepper :fetcher github :repo "joaotavora/sly-stepper")
'';
ignoreCompilationError = true;
};
org-noter = esuper.org-noter.overrideAttrs (attrs: {
# Nixpkgs conditionally patches an older version, which our "9999snapshot" version breaks.
patches = [ ];
});
# Upstream renamed from opencl-mode to opencl-c-mode. melpa2nix requires single-file-package file
# names match the package name. So rename the package (not the file, just in case someone loads it
# explicitly).
opencl-mode = esuper.opencl-c-mode;
# reveal.js is not actually an ELisp package. Doom gets straight.el to install it,
# then makes org-re-reveal use it as data.
revealjs = stdenvNoCC.mkDerivation {
pname = "revealjs";
version = "9999snapshot";
buildPhase = ''
siteDir=$out/share/emacs/site-lisp/revealjs
mkdir -p $siteDir
cp -r css dist js plugin $siteDir/
'';
};
# Make it byte-compile properly.
code-review = esuper.code-review.overrideAttrs (attrs: {
nativeBuildInputs = (attrs.nativeBuildInputs or [ ]) ++ [ git ];
});
# Make it byte-compile (see auctex)
company-auctex = esuper.company-auctex.overrideAttrs (attrs: {
preBuild =
(attrs.preBuild or "")
+ ''
mkdir home
export HOME="$PWD/home"
'';
});
# Make it byte-compile.
#
# TODO ask upstream about missing evil dependency?
# https://github.com/PythonNut/evil-easymotion/commit/fb7182625fcb1b1f7d43f69df620d98aa0f42a86
# removed the dependency, I do not understand why.
evil-easymotion = esuper.evil-easymotion.overrideAttrs (attrs: {
buildInputs = attrs.buildInputs ++ [ eself.evil ];
});
# Other files that fail to byte-compile:
# - rustic-flycheck, no flycheck dependency. Seems undesirable to force.
# - stylus-mode, missing dependency on sws-mode(?)
# See also https://github.com/doomemacs/doomemacs/commit/f9feaec5bd75f4d997e0b07bc5c8b9177be20781
# - xref-js2: upstream bug(?).
# Error: `add-to-list' can't use lexical var `words'; use `push' or `cl-pushnew'
# - several others, looks like mostly missing (frequently optional) deps.
#
# To check for these: `doom-emacs --script build-helpers/byte-compile-check.el`
# TODO: clean up some more load-path clutter?
#
# The single biggest contributors are tree-sitter-langs (73) and ansible (36),
# leaving 48 others.
#
# It looks like upstream has the same issue for both of these.
# For tree-sitter-langs, we do use our own generated derivation (because elpa),
# but the problematic directory is package-specific (queries/).
# For ansible, we use upstream's derivation from melpaPackages.
#
# Since it looks like it's not breaking things and the number of entries added
# to load-path is relatively modest I'm leaving this alone for now.
}