emacs: add service module
This commit is contained in:
parent
c18984c452
commit
0ca1bf3cfd
|
@ -951,6 +951,21 @@ in
|
|||
A new module is available: 'programs.irssi'.
|
||||
'';
|
||||
}
|
||||
|
||||
{
|
||||
time = "2019-02-09T14:09:58+00:00";
|
||||
condition = hostPlatform.isLinux;
|
||||
message = ''
|
||||
A new module is available: 'services.emacs'.
|
||||
|
||||
This module provides a user service that runs the Emacs
|
||||
configured in
|
||||
|
||||
programs.emacs
|
||||
|
||||
as an Emacs daemon.
|
||||
'';
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -87,6 +87,7 @@ let
|
|||
(loadModule ./services/blueman-applet.nix { })
|
||||
(loadModule ./services/compton.nix { })
|
||||
(loadModule ./services/dunst.nix { })
|
||||
(loadModule ./services/emacs.nix { condition = hostPlatform.isLinux; })
|
||||
(loadModule ./services/flameshot.nix { })
|
||||
(loadModule ./services/gnome-keyring.nix { })
|
||||
(loadModule ./services/gpg-agent.nix { })
|
||||
|
|
|
@ -66,7 +66,6 @@ in
|
|||
|
||||
config = mkIf cfg.enable {
|
||||
home.packages = [ cfg.finalPackage ];
|
||||
|
||||
programs.emacs.finalPackage = emacsWithPackages cfg.extraPackages;
|
||||
};
|
||||
}
|
||||
|
|
44
modules/services/emacs.nix
Normal file
44
modules/services/emacs.nix
Normal file
|
@ -0,0 +1,44 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
cfg = config.services.emacs;
|
||||
emacsCfg = config.programs.emacs;
|
||||
emacsBinPath = "${emacsCfg.finalPackage}/bin";
|
||||
|
||||
in
|
||||
|
||||
{
|
||||
options.services.emacs = {
|
||||
enable = mkEnableOption "the Emacs daemon";
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
assertions = [
|
||||
{
|
||||
assertion = emacsCfg.enable;
|
||||
message = "The Emacs service module requires"
|
||||
+ " 'programs.emacs.enable = true'.";
|
||||
}
|
||||
];
|
||||
|
||||
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 = {
|
||||
ExecStart = "${pkgs.stdenv.shell} -l -c 'exec ${emacsBinPath}/emacs --fg-daemon'";
|
||||
ExecStop = "${emacsBinPath}/emacsclient --eval '(kill-emacs)'";
|
||||
Restart = "on-failure";
|
||||
};
|
||||
|
||||
Install = {
|
||||
WantedBy = [ "default.target" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue