Created
December 28, 2018 22:38
-
-
Save Jomik/a5b36f8891d559a8442a014460ddb3d5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ 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