about summary refs log tree commit diff
path: root/README.org
blob: 5738cefe40413c85bb3b4674d14597393749d5ce (plain) (blame)
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
* Emacs overlay for Nixpkgs
** Quickstart
To get up and running quickly, add the following lines to your =/etc/nixos/configuration.nix=:

#+BEGIN_SRC nix
{config, pkgs, callPackage, ... }:
{
# ...

  services.emacs.package = pkgs.emacsUnstable;

  nixpkgs.overlays = [
    (import (builtins.fetchTarball {
      url = https://github.com/nix-community/emacs-overlay/archive/master.tar.gz;
    }))
  ];

# ...
}
#+END_SRC

This configuration will enable this overlay, and define your system-wide emacs package as the =emacsUnstable= attribute it provides.

*NOTE:* Read the "Usage of the overlay" section below for further explanation of this configuration. This has the potential to break things, and will frequently trigger full source rebuilds of emacs.

If you want to enable daemon/server mode, add the following line to the same configuration:

#+BEGIN_SRC nix
services.emacs.enable = true;
#+END_SRC

It is recommended you read Nixpkgs and NixOS documentation on package overlays and overrides to familiarize yourself with the concepts:

 - https://nixos.wiki/wiki/Overlays
 - https://nixos.org/nixpkgs/manual/#chap-overlays

** Contents of the overlay

*** Elpa
Daily generations of Elpa.

*** Melpa / Melpa stable
Daily generations of Melpa & Melpa stable attribute sets.

*** EXWM & needed dependencies
This overlay provides fresh versions of EXWM and dependencies. This is
updated daily.

*** Emacs from Git and latest (including pre-releases)
This overlay also provides two versions (latest from git) for Emacs. These
are updated daily.

These attributes are named =emacsGit= and =emacsUnstable=.
=emacsGit= is built from the latest =master= branch and =emacsUnstable= is built from the latest tag.

Emacs from git is not guaranteed stable and may break your setup at any
time, if it breaks you get to keep both pieces.

Furthermore we provide emacs compiled with the native compilation backend enabled
under the attribute =emacsGcc=.

We also provide two attributes named =emacsGit-nox= and =emacsUnstable-nox=
if you wish to have Emacs built without X dependencies, as well as the
experimental pgtk branch which supports Wayland natively.

** Extra library functionality
This overlay comes with extra functions to generate an Emacs closure
from various types of dependency declaration. (These are abstractions
on top of =emacsWithPackages=.)

For example, =emacsWithPackagesFromUsePackage= adds packages which are
required in a user's config via =use-package= or =leaf=.

#+BEGIN_SRC nix
  {
    environment.systemPackages = [
      (emacsWithPackagesFromUsePackage {
        # Your Emacs config file. Org mode babel files are also
        # supported.
        # NB: Config files cannot contain unicode characters, since
        #     they're being parsed in nix, which lacks unicode
        #     support.
        # config = ./emacs.org;
        config = ./emacs.el;

        # Package is optional, defaults to pkgs.emacs
        package = pkgs.emacsGit;

        # By default emacsWithPackagesFromUsePackage will only pull in
        # packages with `:ensure`, `:ensure t` or `:ensure <package name>`.
        # Setting `alwaysEnsure` to `true` emulates `use-package-always-ensure`
        # and pulls in all use-package references not explicitly disabled via
        # `:ensure nil` or `:disabled`.
        # Note that this is NOT recommended unless you've actually set
        # `use-package-always-ensure` to `t` in your config.
        alwaysEnsure = true;

        # For Org mode babel files, by default only code blocks with
        # `:tangle yes` are considered. Setting `alwaysTangle` to `true`
        # will include all code blocks missing the `:tangle` argument,
        # defaulting it to `yes`.
        # Note that this is NOT recommended unless you have something like
        # `#+PROPERTY: header-args:emacs-lisp :tangle yes` in your config,
        # which defaults `:tangle` to `yes`.
        alwaysTangle = true;

        # Optionally provide extra packages not in the configuration file.
        extraEmacsPackages = epkgs: [
          epkgs.cask
        ];

        # Optionally override derivations.
        override = epkgs: epkgs // {
          weechat = epkgs.melpaPackages.weechat.overrideAttrs(old: {
            patches = [ ./weechat-el.patch ];
          });
        };
      })
    ];
  }
#+END_SRC

Similarly, =emacsWithPackagesFromPackageRequires= adds packages which
are declared in a =.el= package file's =Package-Requires= header, which
can be handy for CI purposes:

#+BEGIN_SRC nix
...
let
  emacsForCI = pkgs.emacsWithPackagesFromPackageRequires {
    packageElisp = builtins.readFile ./flycheck.el;
    extraEmacsPackages = epkgs: [
      epkgs.package-lint
    ];
  };
pkgs.mkShell {
  buildInputs = [ emacsForCI ];
}
#+END_SRC


** Usage of the overlay
*** Latest master each rebuild
One way, and probably the most convenient way to pull in this overlay is by
just fetching the tarball of latest master on rebuild.

This has side-effects if packages breaks or things like that you may want
to be in control of which revision of the overlay you run.

Adding the overlay this way will extend your Emacs packages set to contain
the latest EXWM and dependencies from their respective master and make the
package =emacsGit= available. These of course change quite rapidly and will
cause compilation time.

#+BEGIN_SRC nix
{
  nixpkgs.overlays = [
    (import (builtins.fetchTarball {
      url = https://github.com/nix-community/emacs-overlay/archive/master.tar.gz;
    }))
  ];
}
#+END_SRC

*** Binary cache
You will want to use the [[https://nix-community.org/#binary-cache][nix-community binary cache]]. Where the
overlay's build artefacts are pushed. See [[https://app.cachix.org/cache/nix-community][here]] for installation
instructions.

*** Install directly from the overlay
The repository is meant to be used as an overlay as is explained
above. Still, for experimental purposes, you might want to install a
package directly from the overlay. For example, you can install
=emacsGit= from a clone of this repository with the following command:

#+begin_src shell
  nix-build --expr 'with (import <nixpkgs> { overlays = [ (import ./.) ]; }); emacsGit'
#+end_src

* Community

** IRC
=#nixos-emacs= on =freenode=

** Nixpkgs issues

*** Emacs tracking issue
https://github.com/NixOS/nixpkgs/issues/66303

#  LocalWords:  EXWM NixOS emacsGit
#  LocalWords:  SRC nixpkgs builtins fetchTarball url