# I don't want emacs.desktop file because I only use
# emacsclient.
postInstall = (attrs.postInstall or "") + ''
rm $out/share/applications/emacs.desktop
'';
});
in [ /* ... */ ]
```
:::
After building this file as shown in [](#ex-emacsNix), you
will get an GTK 3-based Emacs binary pre-loaded with your favorite packages.
## Running Emacs as a Service {#module-services-emacs-running}
NixOS provides an optional
{command}`systemd` service which launches
[Emacs daemon](https://www.gnu.org/software/emacs/manual/html_node/emacs/Emacs-Server.html)
with the user's login session.
*Source:* {file}`modules/services/editors/emacs.nix`
### Enabling the Service {#module-services-emacs-enabling}
To install and enable the {command}`systemd` user service for Emacs
daemon, add the following to your {file}`configuration.nix`:
```nix
{
services.emacs.enable = true;
}
```
The {var}`services.emacs.package` option allows a custom
derivation to be used, for example, one created by
`emacsWithPackages`.
Ensure that the Emacs server is enabled for your user's Emacs
configuration, either by customizing the {var}`server-mode`
variable, or by adding `(server-start)` to
{file}`~/.emacs.d/init.el`.
To start the daemon, execute the following:
```ShellSession
$ nixos-rebuild switch # to activate the new configuration.nix
$ systemctl --user daemon-reload # to force systemd reload
$ systemctl --user start emacs.service # to start the Emacs daemon
```
The server should now be ready to serve Emacs clients.
### Starting the client {#module-services-emacs-starting-client}
Ensure that the Emacs server is enabled, either by customizing the
{var}`server-mode` variable, or by adding
`(server-start)` to {file}`~/.emacs`.
To connect to the Emacs daemon, run one of the following:
```
emacsclient FILENAME
emacsclient --create-frame # opens a new frame (window)
emacsclient --create-frame --tty # opens a new frame on the current terminal
```
### Configuring the {var}`EDITOR` variable {#module-services-emacs-editor-variable}
<!--<title>{command}`emacsclient` as the Default Editor</title>-->