1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-12-24 18:59:47 +01:00

emacs: add service module

This commit is contained in:
Jonas Holst Damtoft 2018-12-29 20:11:48 +01:00 committed by Robert Helgesson
parent c18984c452
commit 0ca1bf3cfd
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
4 changed files with 60 additions and 1 deletions

View file

@ -951,6 +951,21 @@ in
A new module is available: 'programs.irssi'. 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.
'';
}
]; ];
}; };
} }

View file

@ -87,6 +87,7 @@ let
(loadModule ./services/blueman-applet.nix { }) (loadModule ./services/blueman-applet.nix { })
(loadModule ./services/compton.nix { }) (loadModule ./services/compton.nix { })
(loadModule ./services/dunst.nix { }) (loadModule ./services/dunst.nix { })
(loadModule ./services/emacs.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/flameshot.nix { }) (loadModule ./services/flameshot.nix { })
(loadModule ./services/gnome-keyring.nix { }) (loadModule ./services/gnome-keyring.nix { })
(loadModule ./services/gpg-agent.nix { }) (loadModule ./services/gpg-agent.nix { })

View file

@ -66,7 +66,6 @@ in
config = mkIf cfg.enable { config = mkIf cfg.enable {
home.packages = [ cfg.finalPackage ]; home.packages = [ cfg.finalPackage ];
programs.emacs.finalPackage = emacsWithPackages cfg.extraPackages; programs.emacs.finalPackage = emacsWithPackages cfg.extraPackages;
}; };
} }

View 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" ];
};
};
};
}