Commit Graph

54 Commits

Author SHA1 Message Date
Brian Leung
d1579a08ec emacs: remove backwards-compatibility aliases 2023-11-22 09:25:50 -03:00
Hraban Luyat
1b26fc011a emacs: allow using as shebang on darwin 2023-09-24 19:50:52 -03:00
Hraban Luyat
949ea0426d emacs: remove unused makeWrapper dependency
As far as I can tell this is unused. The wrapper script is fully custom.
2023-09-24 19:50:52 -03:00
Lin Jian
6505082e72 emacsWithPackages: load compiled site-start.el of $emacs if possible
The first log in *Message* before this patch:

  Loading /nix/store/bikm18vy6v07hmrvrll501i68440w9iw-emacs-29.1-rc1/share/emacs/site-lisp/site-start.el (source)...done

and after this patch:

  Loading /nix/store/bikm18vy6v07hmrvrll501i68440w9iw-emacs-29.1-rc1/share/emacs/site-lisp/site-start (native compiled elisp)...done
2023-08-28 15:46:04 +00:00
Lin Jian
e8f6a5ce34 emacsWithPackages: do not symlink $emacs/share/emacs
I see no reason to symlink this dir.

Doing so may shadow unwanted libraries since the site-start.el of
Emacs adds paths under NIX_PROFILES to load-path.

It is added in [1] to fix "building emacs".  However, I have no issue
in building and using Emacs after removing it.

[1]: https://github.com/NixOS/nixpkgs/pull/89351
2023-08-28 15:46:04 +00:00
Lin Jian
f5fbea9761 emacsWithPackages: do not add the wrapper path twice
"$out/share/emacs/site-lisp" is added to load-path in wrapper.sh[1]
using EMACSLOADPATH and "$out/share/emacs/native-lisp/" is added to
native-comp-eln-load-path in wrapper.sh[2] using
EMACSNATIVELOADPATH. There is no point to add them again here.

Additionally, the trailing "/" in "$out/share/emacs/native-lisp/"
causes duplicate entries in native-comp-eln-load-path:

("/nix/store/hash1-emacs-packages-deps/share/emacs/native-lisp/" ; [3]
 "/home/user/.emacs.d/eln-cache/"
 "/nix/store/hash1-emacs-packages-deps/share/emacs/native-lisp"  ; [2]
 "/nix/store/hash2-emacs-29.1-rc1/lib/emacs/29.1/native-lisp/")

load-path does not change with this patch applied.

[1]: 1476c13422/pkgs/build-support/emacs/wrapper.sh (L47)
[2]: 1476c13422/pkgs/build-support/emacs/wrapper.sh (L50)
[3]: 1476c13422/pkgs/build-support/emacs/wrapper.nix (L166)
2023-08-28 15:46:04 +00:00
Lin Jian
7f8cd3d8f9 emacsWithPackages: remove redundant colons 2023-08-25 17:42:21 +00:00
Artturin
b93da3f4b7 treewide: overrideScope' -> overrideScope
`lib.makeScope` `overrideScope'` has been renamed to `overrideScope`

`fd --type f | xargs sd --string-mode "overrideScope'" "overrideScope"`
2023-08-14 18:46:47 +03:00
adisbladis
5f253d2521 emacs: add back support in wrapper for using passthru.treeSitter
The API was changed in https://github.com/NixOS/nixpkgs/pull/235859.
2023-06-20 02:30:04 +12:00
adisbladis
3ef5accbff emacs: add back support in wrapper for using passthru.nativeComp
The API was changed in https://github.com/NixOS/nixpkgs/pull/235859.
2023-06-20 02:29:20 +12:00
Anderson Torres
5d68e9014c build-support/emacs: synchronize with emacs' modified attributes 2023-06-07 23:26:31 -03:00
Adam Joseph
6c209e862e emacs: path fixes resulting from libgccjit changes
The Nix-driven bootstrap of gcc resulted in some changes to the
structure of the `libgccjit` outpaths, and also added an additional
output (`libgcc`) to `gcc`.

This commit makes the corresponding changes in the `emacs`
derivation in order to not break emacs.

Emacs is the only user of `libgccjit` in nixpkgs at the moment.
2023-04-02 13:49:54 -07:00
Chris Hodapp
1a8edfe192
emacs: Add basic tree-sitter support (#219559)
This commit adds basic support for tree-sitter in the emacs build,
such that (if the user opts into tree-sitter support), tree-sitter
will be enabled and binary library files for tree-sitter can be
included in the `lib` directory of packages passed to
`emacsWithPackages`. The libraries will be aggregated and included in
treesit-extra-load-path.

The previous pattern for this in the community was to add tree-sitter
libaries by patching emacs's `RUNPATH` with `patchelf` in a post-fixup
phase. However, this has the substantial drawback that two different
emacs installations with different lists of available tree-sitter
libraries must be entirely separate builds. By supplying the
tree-sitter libraries in the wrapping layer of `emacsWithpackages`, it
becomes possible to share a single, more-cacheable "core emacs".

This support defaults to "on" only in emacs 29 and up, since previous
versions do not support tree-sitter out of the box.
2023-03-15 16:51:29 +13:00
Thomas Tuegel
017fa2d7a0
emacsWithPackages: Rely on package.el for autoloads
The builtin `package.el` functionality is necessary and sufficient to handle
autoloads in the Emacs wrapper.
2022-07-11 20:22:20 -05:00
Mario Rodas
f73ff5c229 emacsWrapper: add missing variable substitutions to Darwin app 2022-04-22 04:20:00 +00:00
Daniel Nagy
0f316e5553
emacsWrapper: fix mishandling of empty package list
The native compiler of emacs does not handle empty files well.

This arose in https://github.com/NixOS/nixpkgs/pull/168954 .
2022-04-19 21:12:45 +02:00
Daniel Nagy
4489718d8f
emacsWrapper: preload autoloads
This commits changes the Emacs wrapper, in order to preload all autoload
definitions when built with additional packages. The list of all
definitions is generated at build-time. Packages do not need to
be (require)d for them to work.

Before this change, a code like

```sh
nix-shell -I "nixpkgs=$PWD" -p "emacs.pkgs.withPackages(e:[e.magit])" \
          --run "emacs -Q -nw -f magit"
```

will fail with the message `Symbol’s function definition is void: magit`

After the change, the same code above will open Emacs with magit
enabled.

A slightly longer startup time of ~10ms was detected in local, informal
experiments.

More information on autoloading:
https://www.gnu.org/software/emacs/manual/html_node/eintr/Autoload.html
2022-04-17 14:36:24 +02:00
Robert Helgesson
3247e75741
emacs: resolve wrapper load-path at build time
Since the included package set is determined at build time we can also
generate the `subdirs.el` file at build time. This improves startup
time somewhat since we don't have to traverse the directory to add to
`load-path`.

For example,

``` sh-session
$ bench './emacs-old -Q --batch --kill' './emacs-new -Q --batch --kill'
benchmarking bench/./emacs-old -Q --batch --kill
time                 72.77 ms   (71.66 ms .. 73.65 ms)
                     1.000 R²   (0.999 R² .. 1.000 R²)
mean                 72.49 ms   (72.06 ms .. 72.92 ms)
std dev              746.5 μs   (582.4 μs .. 1.008 ms)

benchmarking bench/./emacs-new -Q --batch --kill
time                 40.56 ms   (40.24 ms .. 40.86 ms)
                     1.000 R²   (0.999 R² .. 1.000 R²)
mean                 40.30 ms   (40.12 ms .. 40.51 ms)
std dev              401.9 μs   (311.1 μs .. 555.8 μs)
```

The change does not actually affect the content of `load-path`:

``` sh-session
$ diff -s <(./emacs-old --batch --eval '(prin1 load-path)' | sed -E 's!/nix/store/[[:alnum:]]{32}-!!g') \
          <(./emacs-new --batch --eval '(prin1 load-path)' | sed -E 's!/nix/store/[[:alnum:]]{32}-!!g')
Files /dev/fd/63 and /dev/fd/62 are identical
```

So in principle the only observable effect should be the improved
startup time.
2021-11-14 22:31:48 +01:00
adisbladis
f09a770d9c
Merge pull request #130021 from neosimsim/fix-emacs-override-examples
emacs: fix overrideScope' examples
2021-08-04 03:08:33 -05:00
Alexander Ben Nasrallah
c81250a1d3 emacs: fix overrideScope' examples 2021-07-12 16:48:10 +02:00
Matthew Bauer
8bc10fbc56 Add gcc for emacs wrapper so native-comp works
On macos, we don’t have a gcc executable by default, which is required
for some reason when compiling site-start.
2021-06-23 23:02:11 -05:00
Mauricio Collares
67bbabc0a4 emacs: adapt to renamed native-comp variables 2021-05-06 16:47:21 -03:00
midchildan
7208e57cf6
emacsWithPackages: prevent the UI showing prematurely during startup
This change makes the wrapper script avoid displaying echo area messages
during startup. This helps prevent split second UI glitches early in the
startup process. The messages itself will still be logged and therefore
will not hamper inspection for debugging purposes.
2021-02-25 22:30:40 +09:00
adisbladis
4003f8cbc7
treewide: emacsPackages -> emacs.pkgs & emacsWithPackages -> emacs.pkgs.withPackages
The previous names are now aliases and shouldn't be used anywhere inside nixpkgs.
2021-01-13 17:13:10 +01:00
Alyssa Ross
0f06d94a20 emacs: fix accidental double wrapper (Darwin)
This was already fixed on non-Darwin, but the fix missed that it was
also reintroduced for the Darwin code path at the same time.

Fixes: dd5d2482c9 ("emacs: Fix accidental double wrapping")
2021-01-08 05:45:15 +00:00
Matthieu Le brazidec (r3v2d0g)
bfec6c34b4
emacs: replace 'emacs.nativeComp' in wrapper with 'nativeComp' 2020-12-20 21:15:18 +01:00
adisbladis
dd5d2482c9
emacs: Fix accidental double wrapping
This makeWrapper invocation found it's way back via a rebase.
2020-12-17 02:44:37 +01:00
Tad Fisher
a7cb8e36ac
emacs: Add comp-eln-load-path infrastructure 2020-12-16 19:45:07 +01:00
Mario Rodas
eb9751c6d6 emacsWithPackages: fix application wrapper on darwin 2020-12-12 04:20:00 +00:00
Alyssa Ross
0127013b0f
emacsWithPackages: mutate EMACSLOADPATH correctly
An empty entry in EMACSLOADPATH gets filled with the default value.
This is presumably why the wrapper inserted a colon after the entry it
added for the dependencies.  But this naive approach wasn't always
correct.

For example, if the user ran emacs with EMACSLOADPATH=foo, the wrapper
would insert the default value (by adding the trailing `:') even
though the user was trying to expressly opt out of it.

To do this correctly, here I've replaced makeWrapper with a bespoke
script that will actually parse the EMACSLOADPATH provided in the
environment (if given), and insert the wrapper's load path just before
the default value.  If EMACSLOADPATH is given but contains no default
value, we respect that and don't add the wrapped dependencies at all.
If no EMACSLOADPATH is given, we insert the wrapped dependencies
before the default value, just like before.  In this way, the wrapped
Emacs should now behave as if the wrapped dependencies were part of
Emacs's default load-path value.
2020-12-10 22:35:57 +00:00
DwarfMaster
a9eab6d2b9 Fix building of emacsWithPackages not findind subdirs.el 2020-06-02 11:52:39 +02:00
Robert Helgesson
241e28e3d1
emacs: use runCommand to generate wrapper
This removes the unnecessary compiler build dependency. We also set

    preferLocalBuild = true;
    allowSubstitutes = false;

to not farm out the build on a remote builder or bother with trying to
find a binary substitution.
2019-09-18 22:32:19 +02:00
adisbladis
41d1b8fa88
emacsPackages: Drop old emacsPackages (non-NG) sets
These have been deprecated for a long time now and has not seen much maintenance.
2019-08-30 16:43:16 +01:00
Mohammed Yaseen Mowzer
d17d18ad81 emacs: Link subdirs.el into emacs-packages-deps
Emacs loads all the elisp files in the top-level of the site-lisp
directory. However some packages (e.g. mu4e) put their elisp files in a
subdirectory of site-lisp. Emacs will not load these packages unless
subdirs.el is present.

This commit links the subdirs.el file from the emacs package into the
emacs-package-deps package so that packages that put their elisp files
in a subdirectory of site-lisp are loaded.
2019-02-02 15:37:13 +02:00
John Ericson
b9dce11712 lib: Make overrideScope' which takes arguments in the conventional order
The `overrideScope` bound by `makeScope` (via special `callPackage`)
took an override in the form `super: self { … }`. But this is
dangerously close to the `self: super { … }` form used by *everything*
else, even other definitions of `overrideScope`! Since that
implementation did not even share any code either until I changed it
recently in 3cf43547f4, this inconsistency
is almost certainly an oversight and not intentional.

Unfortunately, just as the inconstency is hard to debug if one just
assumes the conventional order, any sudden fix would break existing
overrides in the same hard-to-debug way. So instead of changing the
definition a new `overrideScope'` with the conventional order is added,
and old `overrideScope` deprecated with a warning saying to use
`overrideScope'` instead. That will hopefully get people to stop using
`overrideScope`, freeing our hand to change or remove it in the future.
2018-09-24 17:50:11 -04:00
Shea Levy
943592f698
Add setFunctionArgs lib function.
Among other things, this will allow *2nix tools to output plain data
while still being composable with the traditional
callPackage/.override interfaces.
2018-01-31 14:02:19 -05:00
Shea Levy
0f925943fd
Fix emacsWithPackages after 7f3ca3e21a.
This is hacky but it does the job, resurrects findInputs from before staging merge
2018-01-04 12:15:55 -05:00
Michael Alan Dorman
ef5ba4d5b2 Fix emacs wrapper expression to honor bash array use
In 8d76eff, @Ericson2314 changed the representation of the value that
`findInputs` generated from a whitespace-separated bunch strings to an
actual array of strings.

Expressions that *consume* that value, however, also needed to be
changed to iterate over all the contents of the array, else they would
only select the first value, which turns out to be somewhat limiting.

Fixes #27873
2017-08-04 07:52:18 -04:00
Matthew Bauer
2c0006521b
emacsWithPackages: wrap MacOS app
fixes #22893
2017-05-20 18:51:32 -05:00
Utku Demir
5a78bed2bb Fix documentation of emacsWithPackages
After [this change](901a778c77), it should be `overrideScope` instead of `override`.
2017-05-02 09:52:04 +12:00
Nicolas Dudebout
9c3852538c emacsWrapper: remove site-start.elc 2016-09-27 16:13:22 -04:00
Thomas Tuegel
64ba7b53f1 Revert "Merge pull request #17806 from matthewbauer/emacs-wrapper"
This reverts commit da68127737, reversing
changes made to 2ba494b728.

These changes are reverted because they cause an incompatibility which
they should not.
2016-08-19 15:09:41 -05:00
Matthew Bauer
6ceedaaee4 emacs: add versatile "emacsWrapper"
"emacsWrapper" replaces emacsWithPackages. In addition to "packagesFun",
emacsWrapper has an optional variable called "execStart". execStart can
be used to append elisp to the default site-start.el script. This is
useful for providing a way to load a user's .emacs.d/init.el
file. "emacsWithPackages" is implemented with emacsWrapper for
convenience and compatability.
2016-08-17 18:19:58 +00:00
Samuel Rivas
67394f9152 emacs: hide wrapper dependencies
Move all the dependencies to their own derivation, so that we don't publish all
of them if the wrapper is installed in a profile.

The previous solution just moved them to a custom directory to avoid conflicts,
this refactors that and completely hides them, while preserving the desired
improvement of adding only one directory to each of the emacs search paths
2016-05-12 22:43:30 +02:00
Samuel Rivas
f1b0d6410e emacsWithPackages: reduce some duplication 2016-04-03 21:21:50 +02:00
Samuel Rivas
2b199537b7 emacsWithPackages: move bin and site-lisp to private share directory
This is to avoid unwanted side effects when installing a wrapped emacs in the environment:

  * All executables in the dependencies become available in the user environment
  * All site-lisp binaries in the dependencies become accessible to unwrapped emacs

Also, both bin and site-lisp would generate conflicts so installing a wrapped emacs becomes really cumbersome
2016-04-03 21:11:38 +02:00
Thomas Tuegel
32c30411cf emacsWithPackages: link packages into single load-path
This should provide a small speed improvement by avoiding having to set
hundreds of load-paths.
2016-01-20 12:53:11 -06:00
Thomas Tuegel
2b1024646b emacsWithPackages: defer loading package.el
Also stops duplicating load paths.
2016-01-20 12:43:21 -06:00
Thomas Tuegel
97e1258ded emacsWithPackages: use local variables correctly 2016-01-20 12:43:00 -06:00
Thomas Tuegel
0bc4af00ee emacsWithPackages: add user documentation 2015-12-19 09:32:16 -06:00