Emacs: Difference between revisions
m →System setup: make it clear the distinction between installing system wide vs home manager |
→Configuration: provide a clearer list of possible ways to configure emacs |
||
| Line 51: | Line 51: | ||
== Configuration == | == Configuration == | ||
==== | ==== NixOS System Configuration ==== | ||
< | |||
System wide configuration of Emacs is limited to only the [https://www.gnu.org/software/emacs/manual/html_node/emacs/Emacs-Server.html Emacs daemon]. To enable Emacs daemon user services system-wide and set as default editor: | |||
{{file|/etc/nixos/configuration.nix|nix|<nowiki> | |||
services.emacs = { | |||
enable = true; | enable = true; | ||
defaultEditor = true; | defaultEditor = true; | ||
}; | }; | ||
</ | </nowiki> | ||
}} | |||
Use <code>emacsclient</code> to connect to the daemon. For a full list of module configuration options, see {{nixos:option|services.emacs}}. | |||
==== Home Manager ==== | |||
[[Home Manager]] provides a larger set of user-specific configuration options for Emacs. | |||
< | |||
A minimal configuration that installs Emacs alongside <code>nix-mode</code> and <code>nixfmt</code> packages: | |||
{{file|home.nix|nix|<nowiki> | |||
programs.emacs = { | programs.emacs = { | ||
enable = true; | enable = true; | ||
package = pkgs.emacs; # replace with pkgs.emacs-gtk if desired | package = pkgs.emacs; # replace with pkgs.emacs-gtk if desired | ||
extraPackages = epkgs: [ | |||
epkgs.nix-mode | |||
epkgs.nixfmt | |||
]; | |||
extraConfig = '' | extraConfig = '' | ||
(setq standard-indent 2) | (setq standard-indent 2) | ||
''; | ''; | ||
}; | }; | ||
</ | </nowiki> | ||
}} | |||
{{note| An alternative option to setting the config inside a Nix string, you can load the config file by <code>extraConfig <nowiki>=</nowiki> builtins.readFile ./emacs_config.el</code>.}} | |||
To search for Emacs plugins within the package set, see {{nixos:package|emacsPackages.*}}. A full list of Home Manager configuration module options can be found [https://home-manager-options.extranix.com/?query=programs.emacs here]. | |||
Home Manager also provides a configuration module for enabling the Emacs daemon: | |||
{{file|home.nix|nix|<nowiki> | |||
# Emacs is running as a daemon here, accesible via the "emacsclient" command | |||
services.emacs = { | |||
enable = true; | |||
defaultEditor = true; | |||
}; | |||
</nowiki> | |||
}} | |||
See [https://home-manager-options.extranix.com/?query=services.emacs the module options] for <code>services.emacs</code> configurations options. | |||
== Tips and Tricks == | == Tips and Tricks == | ||