1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-16 08:09:45 +01:00
home-manager/modules/services/emacs.nix

43 lines
1.1 KiB
Nix
Raw Normal View History

2018-12-29 20:11:48 +01:00
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.emacs;
emacsCfg = config.programs.emacs;
emacsBinPath = "${emacsCfg.finalPackage}/bin";
2020-02-02 00:39:17 +01:00
in {
options.services.emacs = { enable = mkEnableOption "the Emacs daemon"; };
2018-12-29 20:11:48 +01:00
config = mkIf cfg.enable {
2020-02-02 00:39:17 +01:00
assertions = [{
assertion = emacsCfg.enable;
message = "The Emacs service module requires"
+ " 'programs.emacs.enable = true'.";
}];
2018-12-29 20:11:48 +01:00
systemd.user.services.emacs = {
Unit = {
Description = "Emacs: the extensible, self-documenting text editor";
2020-02-02 00:39:17 +01:00
Documentation =
"info:emacs man:emacs(1) https://gnu.org/software/emacs/";
# Avoid killing the Emacs session, which may be full of
# unsaved buffers.
X-RestartIfChanged = false;
2018-12-29 20:11:48 +01:00
};
Service = {
2020-02-02 00:39:17 +01:00
ExecStart =
"${pkgs.runtimeShell} -l -c 'exec ${emacsBinPath}/emacs --fg-daemon'";
2018-12-29 20:11:48 +01:00
ExecStop = "${emacsBinPath}/emacsclient --eval '(kill-emacs)'";
Restart = "on-failure";
};
2020-02-02 00:39:17 +01:00
Install = { WantedBy = [ "default.target" ]; };
2018-12-29 20:11:48 +01:00
};
};
}