mirror of
https://github.com/nix-community/home-manager
synced 2024-12-25 03:09:47 +01:00
emacs: add service module
This commit is contained in:
parent
c18984c452
commit
0ca1bf3cfd
4 changed files with 60 additions and 1 deletions
|
@ -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.
|
||||||
|
'';
|
||||||
|
}
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 { })
|
||||||
|
|
|
@ -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;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
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