Like the nix-community emacs-overlay, this flake adds additional GNU Emacs features and packages to nixpkgs.
This flake uses and extends emacs-overlay
while providing the ability to separately control the version of Emacs being used.
All of the emacs-overlay
targets are provided and extended. They all include emacs-libvterm support and the graphic interface packages are built with GTK3 and embedded native widgets with WebKit enabled.
The flake also takes an emacs-src
input
, which is used to provide the emacsStable
, emacsStablePgtk
, and emacsStable-nox
targets. These have all of the same benefits of the extended emacs-overlay
packages, but allow for independent control of the Emacs version being built.
On Darwin (macOS) the default emacs
package is emacsStablePgtk
using the Pure GTK interfaces. Other platforms default to emacsStable
with a GTK3 X Windows interface. The reason for this is that I frequently use X11 forwarding on non-Mac hosts and the Pure GTK version is not currently[fn:1] stable over X. However, you are free to use any of the other Emacs package outputs on whichever systems you please.
Simple add emacs-flake to your inputs
:
inputs = {
emacs.url = github:rdparker/emacs-flake;
...
};
Once this is done the usage is the same as specified in the Emacs Installation section on the NixOS Wiki
{
programs.emacs = {
enable = true;
package = pkgs.emacs; # replace with pkgs.emacsStablePgtk, or a
# version provided by the flake if desired.
extraConfig = ''
(setq standard-indent 2)
'';
};
}
See the Home-Manager manual for a full list of options.
Emacs can be installed in the same way as other packages:
{
environment.systemPackages = with pkgs; [
emacs # replace with emacsStablePgtk, or a version provided by
# the flake if desired.
];
}
Many Emacs users run Emacs as a daemon and access Emacs via the emacsclient
command. NixOS provides a systemd
service to facilitate this, which you can enable by adding the following to your configuration.nix
:
{
services.emacs = {
enable = true;
package = pkgs.emacs; # replace with emacsStablePgtk, or a version
# provided by the flake if desired.
};
}
Out of the box, non-“Mac Port” versions of Emacs will not be picked up properly by window managers like Yabai because Emacs does not set the correct macOS window role. This flake patches that. However, even with the patch, Yabai may not correctly pick up Emacs if you invoke the emacs
binary directly from a shell. For Emacs to work properly with window managers you must invoke it by running the macOS app that is generated when you install Emacs with nix. You can setup an alias to do this like so (replace pkgs.emacs
with the package you are using):
programs.zsh = {
enable = true;
shellAliases = {
emacs = "${pkgs.emacs}/Applications/Emacs.app/Contents/MacOS/Emacs";
};
};
*
[fn:1] May 2, 2023.