Skip to content

Instantly share code, notes, and snippets.

@Jomik
Created December 28, 2018 22:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jomik/a5b36f8891d559a8442a014460ddb3d5 to your computer and use it in GitHub Desktop.
Save Jomik/a5b36f8891d559a8442a014460ddb3d5 to your computer and use it in GitHub Desktop.
{ lib, config, pkgs, ... }:
with lib;
let
cfg = config.services.emacs;
package = config.programs.emacs.finalPackage;
in {
options.services.emacs.enable = mkEnableOption "Emacs";
config = mkIf cfg.enable {
assertions = [
{
assertion = config.programs.emacs.enable;
message = "Must enable programs.emacs.enable.";
}
];
systemd.user.services.emacs = {
Unit = {
Description = "Emacs: the extensible, self-documenting text editor";
Documentation = "info:emacs man:emacs(1) https://gnu.org/software/emacs/";
};
Service = {
Type = "simple";
ExecStart = "${pkgs.stdenv.shell} -l -c 'exec ${package}/bin/emacs --fg-daemon'";
ExecStop = "${package}/bin/emacsclient --eval '(kill-emacs)'";
Restart = "on-failure";
};
Install = {
WantedBy = [ "default.target" ];
};
};
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment